Skip to content

Commit

Permalink
Fixes tag validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kalvn authored Mar 13, 2018
1 parent bbe0e45 commit f293ee3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions shaarli2mastodon.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,9 @@ function isLinkNote($link){
* @return string The tag modified to be valid.
*/
function tagify($tag){
return '#' . preg_replace('/[^0-9a-zA-Z]/m', '', $tag);
}
// Regex inspired by https://gist.github.com/janogarcia/3946583
// TODO validate real hashtag rules
// - only UTF-8 characters plus underscore
// - must not contain only numbers. At least one alpha character or underscore
return '#' . preg_replace('/[^0-9_\p{L}]/u', '', $tag);
}

0 comments on commit f293ee3

Please sign in to comment.