Skip to content

Commit

Permalink
tweak \D and comment block for at-username regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Unihedro committed May 24, 2016
1 parent ae15add commit 5cfe876
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/templating/StringHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ trait StringHelper { self: NumberHelper =>
}
}

// Matches a lichess username with a '@' prefix only if it doesn't follow another '@',
// if it isn't after a word character (that'd be an email) and fits constains in
// Matches a lichess username with a '@' prefix only if the next char isn't a digit,
// if it isn't after a word character (that'd be an email) and fits constraints in
// https://github.com/ornicar/lila/blob/master/modules/security/src/main/DataForm.scala#L34-L44
// Example: everyone says @ornicar is a pretty cool guy
// False example: Write to [email protected], @1
private val atUsernameRegex = """\B@(?>\D[\w-]{1,19})(?![\w-])""".r
private val atUsernameRegex = """\B@(?>[a-zA-Z_-][\w-]{1,19})(?![\w-])""".r

This comment has been minimized.

Copy link
@niklasf

niklasf May 24, 2016

Member

Can you include all unicode word characters in the negative lookahead? So as to not match @Eichhörnchen.

This comment has been minimized.

Copy link
@Unihedro

Unihedro May 24, 2016

Author Contributor

Thanks! I didn't consider that.


private val urlRegex = """(?i)\b((?:https?:https://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s<>]+|\(([^\s<>]+|(\([^\s<>]+\)))*\))+(?:\(([^\s<>]+|(\([^\s<>]+\)))*\)|[^\s`!\[\]{};:'".,<>?«»“”‘’]))""".r

Expand Down

0 comments on commit 5cfe876

Please sign in to comment.