Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2e4f4c0f2e596749509d4f3d9d3768bbac632719
      
https://github.com/WebKit/WebKit/commit/2e4f4c0f2e596749509d4f3d9d3768bbac632719
  Author: Razvan Caliman <rcali...@apple.com>
  Date:   2025-09-04 (Thu, 04 Sep 2025)

  Changed paths:
    M Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
    M Source/WebInspectorUI/UserInterface/Base/Setting.js
    M Source/WebInspectorUI/UserInterface/Base/Utilities.js
    M Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js

  Log Message:
  -----------
  Web Inspector: Searching on certain text fails to find matches
https://bugs.webkit.org/show_bug.cgi?id=297790
rdar://159272725

Reviewed by Devin Rousso.

Web Inspector performs a search for a query against multiple backend endpoints 
to find matches:
- `DOMAgent.performSearch()`
- `PageAgent.searchInResources()`
- `DebuggerAgent.searchInContent()`
- `PageAgent.searchInResource()`

The frontend applies a regex of the same query on the text line matches 
returned by the backend.
It does this to highlight the search query in the results sidebar.

The frontend regex is slightly different than the one on the backend.

The frontend regex generated by:
`WI.SearchUtilities.searchRegExpForString()` -> 
`WI.SearchUtilities._regExpForString()` -> `simpleGlobStringToRegExp()`
considers an unescaped asterisk (*) a glob matching pattern and wraps the regex 
with \b (word boundary)
mostly to satisfy the user experience of matching against filenames.

The backend regex does not make this distinction:
`ContentSearchUtilities::createRegularExpressionForString()`.

But * in a CSS selector means something else. There are patterns where valid 
CSS selectors
are not bounded by word characters, like `* :not(.foo)`. This fails the 
frontend regex check in
`WI.SearchSidebarPanel.prototype.performSearch()` -> `forEach()` which then 
ignores
the valid matches returned by the backend (which does not employ the glob 
matching pattern).

The fact that frontend and backend use different regexes is a bug in itself.

This patch guards the current glob pattern matching behavior with strict word 
boundaries
behind a new experimental setting (disabled by default) so the two regexes 
match by default.

* Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js:
* Source/WebInspectorUI/UserInterface/Base/Setting.js:
* Source/WebInspectorUI/UserInterface/Base/Utilities.js:
* Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js:

Canonical link: https://commits.webkit.org/299541@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to