Skip to content

Commit

Permalink
Escape highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby222 committed Feb 20, 2025
1 parent 57a396f commit 4641f0a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ public void UpdateHighlights(string? newHighlights = null)
: highlights.Split("\n");

_highlights.Clear();
// If the word is surrounded by "" we replace them with a whole-word regex tag.
_highlights.AddRange(allHighlights.Select(highlight => highlight.Replace("\"", "\\b")));
// Use `"` as layman symbol for Regex `\b`, ignore all other special sequences
// (Without the escape, a name like `Robert'); DROP TABLE users; --` breaks all messsages)
_highlights.AddRange(allHighlights.Select(highlight => Regex.Escape(highlight).Replace("\"", "\\b")));

Check failure on line 102 in Content.Client/_DV/UserInterfaces/Systems/Chat/ChatUIController.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The name 'Regex' does not exist in the current context

Check failure on line 102 in Content.Client/_DV/UserInterfaces/Systems/Chat/ChatUIController.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The name 'Regex' does not exist in the current context

Check failure on line 102 in Content.Client/_DV/UserInterfaces/Systems/Chat/ChatUIController.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The name 'Regex' does not exist in the current context

Check failure on line 102 in Content.Client/_DV/UserInterfaces/Systems/Chat/ChatUIController.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The name 'Regex' does not exist in the current context

Check failure on line 102 in Content.Client/_DV/UserInterfaces/Systems/Chat/ChatUIController.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The name 'Regex' does not exist in the current context

Check failure on line 102 in Content.Client/_DV/UserInterfaces/Systems/Chat/ChatUIController.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The name 'Regex' does not exist in the current context

Check failure on line 102 in Content.Client/_DV/UserInterfaces/Systems/Chat/ChatUIController.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The name 'Regex' does not exist in the current context

Check failure on line 102 in Content.Client/_DV/UserInterfaces/Systems/Chat/ChatUIController.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The name 'Regex' does not exist in the current context

// Arrange the list in descending order so that when highlighting,
// the full word (eg. "Security") appears before the abbreviation (eg. "Sec").
Expand Down

0 comments on commit 4641f0a

Please sign in to comment.