[Pkg-mozext-commits] [greasemonkey] 01/06: Fix full wildcard host patterns in @match.

David Prévot taffit at moszumanska.debian.org
Fri Apr 18 13:28:24 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit 05edf947ea0ec6a9db4c262f359ea5f35218efbd
Author: Ventero <ventero at ventero.de>
Date:   Sun Apr 13 03:24:18 2014 +0200

    Fix full wildcard host patterns in @match.
    
    This was broken by 79ea1be8b106331f1e25ea3d46324cd3ed974fbb.
    Fixes #1912.
---
 modules/third-party/MatchPattern.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/third-party/MatchPattern.js b/modules/third-party/MatchPattern.js
index f4e5275..d2383e6 100644
--- a/modules/third-party/MatchPattern.js
+++ b/modules/third-party/MatchPattern.js
@@ -98,11 +98,14 @@ function MatchPattern(pattern) {
     // GM_convert2RegExp) to properly handle *.example.tld, which should match
     // example.tld and any of its subdomains, but not anotherexample.tld.
     this._hostExpr = new RegExp("^" +
-        // The only character that's valid in a hostname and needs to be escaped
-        // for regexps is ".".
-        host.replace(/\./g, "\\.")
-        // Then, handle "*.", which by now has been escaped to "*\.".
-            .replace(/\*\\./, "(.*\\.)?") + "$", "i");
+        // Two characters in the host portion need special treatment:
+        //   - ". should not be treated as a wildcard, so we escape it to \.
+        //   - if the hostname only consists of "*" (i.e. full wildcard),
+        //     replace it with .*
+        host.replace(/\./g, "\\.").replace(/^\*$/, ".*")
+        // Then, handle the special case of "*." (any or no subdomain) for match
+        // patterns. "*." has been escaped to "*\." by the replace above.
+            .replace("*\\.", "(.*\\.)?") + "$", "i");
   } else {
     // If omitted, then it means "", an alias for localhost.
     this._hostExpr = /^$/;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list