Skip to content

Commit

Permalink
Disallow the usage of < and > in Slug rule (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhuet authored and Rick van der Staaij committed Jul 5, 2017
1 parent 6a66c07 commit f2fe5f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FilterRule/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function filter($value)

$value = transliterator_transliterate($this->transliterator, $value);
$value = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $value);
$value = preg_replace('/[-$?\s]+/', '-', $value);
$value = preg_replace('/[-$?\s<>]+/', '-', $value);
$value = trim($value, '-');
return strtolower($value);
}
Expand Down
1 change: 1 addition & 0 deletions tests/FilterRule/SlugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function getSlugResults()
{
return [
['', '', '', ''],
['Do not try this %27"--></style></script><script>alert("at home")</script>', 'do-not-try-this-27-style-script-script-alertat-home-script', '', ''],
['This is a great stuff to slug !', 'this-is-a-great-stuff-to-slug', '', ''],
['That too with somê spéciàl châractèr$ from €ope !', 'that-too-with-some-special-character-from-europe', '', ''],
['A æ Übérmensch på høyeste nivå! И я люблю PHP ! fi', 'a-ae-ubermensch-pa-hoyeste-niva-i-a-lublu-php-fi', '', ''],
Expand Down

0 comments on commit f2fe5f2

Please sign in to comment.