Uncaught Exception: SyntaxError: Invalid regular expression: \ at end of pattern
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Mar 2016 04:42:21 +0000 (04:42 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Mar 2016 04:42:21 +0000 (04:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155556
<rdar://problem/25200058>

Reviewed by Timothy Hatcher.

Use simpleGlobStringToRegExp, which returns a valid regular expression
for strings with trailing backslashes, and also provides globbing.
String.escapeForRegExp returns a JS string ending in "\\", which isn't
a valid regular expression.

* UserInterface/Views/OpenResourceDialog.js:
(WebInspector.OpenResourceDialog):
(WebInspector.OpenResourceDialog.prototype._handleMousedownEvent):
Fixed typo.

(WebInspector.OpenResourceDialog.prototype._updateFilter):
Switch to simpleGlobStringToRegExp.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198317 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/OpenResourceDialog.js

index 8ada0be..db289b1 100644 (file)
@@ -1,3 +1,24 @@
+2016-03-16  Matt Baker  <mattbaker@apple.com>
+
+        Uncaught Exception: SyntaxError: Invalid regular expression: \ at end of pattern
+        https://bugs.webkit.org/show_bug.cgi?id=155556
+        <rdar://problem/25200058>
+
+        Reviewed by Timothy Hatcher.
+
+        Use simpleGlobStringToRegExp, which returns a valid regular expression
+        for strings with trailing backslashes, and also provides globbing.
+        String.escapeForRegExp returns a JS string ending in "\\", which isn't
+        a valid regular expression.
+
+        * UserInterface/Views/OpenResourceDialog.js:
+        (WebInspector.OpenResourceDialog):
+        (WebInspector.OpenResourceDialog.prototype._handleMousedownEvent):
+        Fixed typo.
+
+        (WebInspector.OpenResourceDialog.prototype._updateFilter):
+        Switch to simpleGlobStringToRegExp.
+
 2016-03-14  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Show path from root to instances in the Heap Snapshot content view
index 1dd0bc4..7ee90e2 100644 (file)
@@ -168,7 +168,7 @@ WebInspector.OpenResourceDialog = class OpenResourceDialog extends WebInspector.
         this._inputElement.select();
 
         // This ensures we don't get a "blur" event triggered for the text field
-        // which would end up dimissing the dialog, which is not the intent.
+        // that would cause the dialog to be dismissed.
         event.preventDefault();
     }
 
@@ -194,11 +194,8 @@ WebInspector.OpenResourceDialog = class OpenResourceDialog extends WebInspector.
         if (!filterText)
             return;
 
-        let escapedFilterText = filterText.escapeForRegExp();
-        let r0 = new RegExp("^" + escapedFilterText, "i");
-        let r1 = simpleGlobStringToRegExp(filterText, "i");
-        let r2 = new RegExp("^" + escapedFilterText.toUpperCase().split("").join(".*?"));
-        let filters = [r0, r1, r2];
+        // FIXME: <https://webkit.org/b/155324> Web Inspector: Improve filtering in OpenResourceDialog
+        let filters = [simpleGlobStringToRegExp(filterText)];
 
         for (let resource of this._resources) {
             for (let i = 0; i < filters.length; ++i) {