brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.91k stars 2.34k forks source link

HTTPS Everywhere uses regular expressions which are not supported by re2 #23861

Open fmarier opened 2 years ago

fmarier commented 2 years ago

The HTTPS Everywhere ruleset appears to contain regular expressions that our parser (re2) doesn't support.

For example, these rules:

        {
          "from": "^http://advertisingcentral\\.yahoo\\.com/+(?=$|\\?)",
          "to": "https://advertising.yahoo.com/"
        },
        {
          "from": "^http://fantasysports\\.yahoo\\.com/(?=$|\\?)",
          "to": "https://sports.yahoo.com/fantasy"
        },

Steps to Reproduce

  1. Start Brave from a terminal.
  2. Type yahoo.ca in the URL and press Enter.

Actual result:

The following error messages are printed to the terminal:

../../third_party/re2/src/re2/re2.cc:205: Error parsing '^http://advertisingcentral\.yahoo\.com/+(?=$|\?)': invalid perl operator: (?=
../../third_party/re2/src/re2/re2.cc:205: Error parsing '^http://fantasysports\.yahoo\.com/(?=$|\?)': invalid perl operator: (?=

Expected result:

The rules should either be supported or ignored. We should not try to run the ones we don't support.

This could be fixed in code, or we could clean up the ruleset.

Reproduces how often:

100% reproducible.

Desktop Brave version:

Brave | 1.42.45 Chromium: 103.0.5060.70 (Developer Build) (64-bit)
Revision | 1543faf9f70e61c6f6e9c01ff20a2e3cf2ad55dc-refs/branch-heads/5060_53@{#4}
OS | Linux
ShivanKaul commented 2 years ago

We also should not just ignore this in brave-core code, we should at least log it