Skip to content

Commit

Permalink
Merge branch 'release/3.2.49' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Welch committed Mar 24, 2020
2 parents c35aad8 + 863ca55 commit 82f4a25
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# SEOmatic Changelog

## 3.2.49 - 2020.03.24
### Added
* Aliases will now auto-suggest in the Site URL Override settings field
* SEOmatic now will replace any stripped HTML tags with a space, so that the text is more readable

### Fixed
* The Site URL Override is now parsed for both aliases and environment variables

### Security
* Ensure that URLs are `urldecode`d before attempting to use a RegEx to strip tags from them

## 3.2.48 - 2020.03.18
### Added
* Added batching to sitemap generation so that the memory used is fixed, and no longer dependent on how many sitemap entries are being processed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-seomatic",
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
"type": "craft-plugin",
"version": "3.2.48",
"version": "3.2.49",
"keywords": [
"craft",
"cms",
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/DynamicMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static function sanitizeUrl(string $url, bool $checkStatus = true): strin
$url = UrlHelper::stripQueryString($url);
// HTML decode the entities, then strip out any tags
$url = html_entity_decode($url, ENT_NOQUOTES, 'UTF-8');
$url = urldecode($url);
$url = strip_tags($url);

// If this is a >= 400 status code, set the canonical URL to nothing
Expand Down Expand Up @@ -647,6 +648,7 @@ public static function getLocalizedUrls(string $uri = null, int $siteId = null):
$url = UrlHelper::absoluteUrlWithProtocol($url);

$url = $url ?? '';
$url = self::sanitizeUrl($url);
$language = $site->language;
$ogLanguage = LocalizationHelper::normalizeOgLocaleLanguage($language);
$hreflangLanguage = $language;
Expand Down
19 changes: 17 additions & 2 deletions src/helpers/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,30 @@ public static function extractTextFromField($field): string
$result = self::extractTextFromTags($field);
} else {
if (\is_array($field)) {
$result = strip_tags((string)$field[0]);
$result = self::smartStripTags((string)$field[0]);
} else {
$result = strip_tags((string)$field);
$result = self::smartStripTags((string)$field);
}
}

return $result;
}

/**
* Strip HTML tags, but replace them with a space rather than just eliminating them
*
* @param $str
* @return string
*/
public static function smartStripTags($str)
{
$str = str_replace('<', ' <', $str);
$str = strip_tags($str);
$str = str_replace(' ', ' ', $str);

return $str;
}

/**
* Extract concatenated text from all of the tags in the $tagElement and
* return as a comma-delimited string
Expand Down
1 change: 1 addition & 0 deletions src/helpers/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static function siteUrl(string $path = '', $params = null, string $scheme
{
$siteUrl = Seomatic::$settings->siteUrlOverride;
if (!empty($siteUrl)) {
$siteUrl = MetaValue::parseString($siteUrl);
return rtrim($siteUrl, '/').'/'.ltrim($path, '/');
}

Expand Down
1 change: 1 addition & 0 deletions src/templates/settings/plugin/_includes/general.twig
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
label: "Site URL Override"|t("seomatic"),
instructions: "SEOmatic uses the Craft `siteUrl` to generate the external URLs. If you are using it in a non-standard environment, such as a headless GraphQL or ElementAPI server, you can override what it uses for the `siteUrl` below."|t("seomatic"),
suggestEnvVars: true,
suggestAliases: true,
id: "siteUrlOverride",
name: "siteUrlOverride",
value: settings.siteUrlOverride,
Expand Down

0 comments on commit 82f4a25

Please sign in to comment.