mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 22:27:25 +08:00
a8f16503e2
For users to be able to add square brackets inside of links using the new format, the regular expression used for parsing those links contained a balancing group, which can be used for matching pairs of tokens (in this case, opening and closing brackets, in that order). However, this means that users could not post links with unmatched brackets inside of them (ie. ones that contain single brackets, or a closing bracket and then an opening one). Allow for escaping opening and closing brackets using the backslash character. The change substitutes this old fragment of the regex in the display text group: [^\[\]]* // any character other than closing/opening bracket for this one: (((?<=\\)[\[\]])|[^\[\]])* The second pattern in the alternative remains the same; the first one performs the escaping, as follows: ( (?<=\\) // positive lookbehind expression: // this match will succeed, if the next expression // is preceded by a single backslash [\[\]] // either an opening or closing brace ) Since the entire display group is matched, unfortunately the lookbehind expression does not actually strip the backslashes, so they are manually stripped in handleMatches. As demonstrated in the unit tests attached, this also allows balanced brackets to be mixed with escaped ones. |
||
---|---|---|
.. | ||
Audio | ||
Beatmaps | ||
Configuration | ||
Database | ||
Graphics | ||
Input | ||
IO | ||
IPC | ||
Migrations | ||
Online | ||
Overlays | ||
Properties | ||
Replays | ||
Rulesets | ||
Scoring | ||
Screens | ||
Skinning | ||
Storyboards | ||
Tests | ||
Users | ||
Utils | ||
osu!.res | ||
osu.Game.csproj | ||
OsuGame.cs | ||
OsuGameBase.cs |