Skip to content

Commit

Permalink
Reduce chance of creating double space when replacing control charact…
Browse files Browse the repository at this point in the history
…ers. Update changelog. #80
  • Loading branch information
mmikkel committed Jan 18, 2024
1 parent f056fd8 commit 27d6b8e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Changed
- Elements without URIs are now explicitly excluded from sitemaps.
- Newlines, returns and other control characters in meta text values are now replaced with a literal space. #80

## 2.1.3 - 2024-01-04
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/SEOMateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public static function getStringPropertyValue(mixed $input): ?string
$value = (string)$input;

// Replace all control characters, newlines and returns with a literal space
$value = preg_replace('/[[:cntrl:]](?! )/', ' ', $value);
$value = preg_replace('/(?<!\s)[[:cntrl:]]|(?<=[[:cntrl:]])\s/', ' ', $value);
$value = preg_replace('/[[:cntrl:]]/', '', $value);

// Add literal spaces after linebreak elements and closing paragraph tags, to avoid words being joined together after stripping tags
Expand Down

0 comments on commit 27d6b8e

Please sign in to comment.