[epiphany] EphyUriTester: Ensure "||" rules are anchored at the start



commit 4d873f4223217026b4ff6355a68cc86f62d65db2
Author: Emanuele Aina <emanuele aina collabora com>
Date:   Mon Nov 9 17:10:45 2015 +0000

    EphyUriTester: Ensure "||" rules are anchored at the start
    
    Filter rules beginning with "||" mean that the following expression must
    match (at least partially) the domain.
    
    This means that "||example.com/foo" should match "foo.example.com/foo"
    but not "fooexample.com/foo" nor
    "example.com/bar?redir=example.com/foo" while the current code will
    happily match all of them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754954

 embed/web-extension/ephy-uri-tester.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/embed/web-extension/ephy-uri-tester.c b/embed/web-extension/ephy-uri-tester.c
index 955e327..5559a6f 100644
--- a/embed/web-extension/ephy-uri-tester.c
+++ b/embed/web-extension/ephy-uri-tester.c
@@ -699,7 +699,10 @@ ephy_uri_tester_parse_line (EphyUriTester *tester, char *line)
     {
       (void)*line++;
       (void)*line++;
-      ephy_uri_tester_add_url_pattern (tester, "", "fulluri", line);
+      /* set a regex prefix to ensure that '||' patterns are anchored at the
+       * start and that any characters (if any) preceding the domain specified
+       * by the rule is separated from it by a dot '.'  */
+      ephy_uri_tester_add_url_pattern (tester, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?", "fulluri", line);
       return;
     }
   if (line[0] == '|')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]