Skip to content

Commit

Permalink
Merge pull request #6 from chrometoasters/bugfix/issue5
Browse files Browse the repository at this point in the history
Bugfix/issue5
  • Loading branch information
normann committed Dec 8, 2019
2 parents 937cd97 + 37355c2 commit 668eb4c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/extensions/MetaDescriptionFallbackExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Control\Controller;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\FieldType\DBText;

/**
* Class MetaDescriptionFallbackExtension
Expand Down Expand Up @@ -96,7 +97,8 @@ public function getGeneralMetaDescription($dataObject = null)
// add a space to closing </p> to prevent bunching, strip all tags and replace multiple spaces with a single one
$metaDescription = preg_replace('/\s+/', ' ', strip_tags(trim(str_replace('</p>', '</p> ', $metaDescription))));

return $metaDescription;
// call ATT() on an instance of DBText
return DBText::create()->setValue($metaDescription)->ATT();
}


Expand All @@ -111,7 +113,7 @@ public function MetaTags(&$tags)

if (!empty($metaDescription)) {
$tag = sprintf('<meta name="description" content="%s" />', $metaDescription);
$replacePattern = '/<meta.*?name="description".*?\/>/';
$replacePattern = '/<meta.*?name="description".*?\/>/sU';

// replace if present, append otherwise
if (preg_match($replacePattern, $tags)) {
Expand Down

0 comments on commit 668eb4c

Please sign in to comment.