mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-24 23:09:10 -05:00
Chat: Don't allow unmatched square brackets in hyperlinks (#10681)
This commit is contained in:
parent
e8e6ac218e
commit
7a8ebe8155
|
|
@ -39,7 +39,9 @@ REGEXFREE SOURCE FOR LINKREGEX
|
|||
|
|
||||
# parentheses in URLs should be matched, so they're not confused
|
||||
# for parentheses around URLs
|
||||
\( ( [^\\s()<>&] | & )* \)
|
||||
\( ( [^\s()<>&[\]] | & )* \)
|
||||
|
|
||||
\[ ( [^\s()<>&[\]] | & )* ]
|
||||
)*
|
||||
# URLs usually don't end with punctuation, so don't allow
|
||||
# punctuation symbols that probably arent related to URL.
|
||||
|
|
@ -47,7 +49,7 @@ REGEXFREE SOURCE FOR LINKREGEX
|
|||
[^\s()[\]{}\".,!?;:&<>*`^~\\]
|
||||
|
|
||||
# annoyingly, Wikipedia URLs often end in )
|
||||
\( ( [^\s()<>&] | & )* \)
|
||||
\( ( [^\s()<>&[\]] | & )* \)
|
||||
)
|
||||
)?
|
||||
)?
|
||||
|
|
@ -58,7 +60,7 @@ REGEXFREE SOURCE FOR LINKREGEX
|
|||
(?! [^ ]*> )
|
||||
|
||||
*/
|
||||
export const linkRegex = /(?:(?:https?:\/\/[a-z0-9-]+(?:\.[a-z0-9-]+)*|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+|\b[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:(?:com?|org|net|edu|info|us|jp)\b|[a-z]{2,3}(?=:[0-9]|\/)))(?::[0-9]+)?(?:\/(?:(?:[^\s()&<>]|&|"|\((?:[^\\s()<>&]|&)*\))*(?:[^\s()[\]{}".,!?;:&<>*`^~\\]|\((?:[^\s()<>&]|&)*\)))?)?|[a-z0-9.]+@[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,})(?![^ ]*>)/ig;
|
||||
export const linkRegex = /(?:(?:https?:\/\/[a-z0-9-]+(?:\.[a-z0-9-]+)*|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+|\b[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:(?:com?|org|net|edu|info|us|jp)\b|[a-z]{2,3}(?=:[0-9]|\/)))(?::[0-9]+)?(?:\/(?:(?:[^\s()&<>]|&|"|\((?:[^\s()<>&[\]]|&)*\)|\[(?:[^\s()<>&[\]]|&)*])*(?:[^\s()[\]{}".,!?;:&<>*`^~\\]|\((?:[^\s()<>&[\]]|&)*\)))?)?|[a-z0-9.]+@[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,})(?![^ ]*>)/ig;
|
||||
|
||||
/**
|
||||
* A span is a part of the text that's formatted. In the text:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user