1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 19:27:26 +08:00
osu-lazer/osu.Game/Online/Chat
Bartłomiej Dach a8f16503e2 Add backslash escaping to new link format
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.
2019-09-03 23:18:39 +02:00
..
Channel.cs Adjust namespaces 2019-02-21 19:05:52 +09:00
ChannelManager.cs formatting inspection 2 2019-08-08 09:02:09 +02:00
ChannelType.cs Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
DrawableLinkCompiler.cs Move TooltipText to OsuClickableContainer 2019-05-21 13:51:38 +09:00
ErrorMessage.cs Move system user colour assignment to ensure consistency 2019-08-08 17:10:06 +09:00
ExternalLinkOpener.cs Adjust namespaces 2019-02-21 19:05:52 +09:00
InfoMessage.cs Fix remaining issues 2019-02-28 13:31:40 +09:00
LocalEchoMessage.cs Fix remaining issues 2019-02-28 13:31:40 +09:00
LocalMessage.cs Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
Message.cs Remove unused property from chat message 2019-06-18 14:22:59 +09:00
MessageFormatter.cs Add backslash escaping to new link format 2019-09-03 23:18:39 +02:00
StandAloneChatDisplay.cs Fix DrawableChannel async flow 2019-06-20 23:01:39 +09:00