Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Blocking JavaScript does not work in local html files (file://...) if the character encoding is not specified. #267

Open
9 tasks done
achvo opened this issue Jun 10, 2020 · 1 comment
Labels
something to address something to address

Comments

@achvo
Copy link

achvo commented Jun 10, 2020

Prerequisites

  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
  • This is not a support issue or a question
    • Support issues and questions are handled at /r/uMatrix
  • I tried to reproduce the issue when...
    • uMatrix is the only extension
    • uMatrix with default lists/settings
    • using a new, unmodified browser profile
  • I am running the latest version of uMatrix
  • I checked the documentation to understand that the issue I report is not a normal behavior
  • I used the logger to rule out that the issue is caused by my ruleset

Description

Blocking JavaScript does not work in local html files (file://...) if the character encoding is not specified.
This bug does not occur if the character encoding is specified.

A specific URL where the issue occurs

See Steps to Reproduce.

Steps to Reproduce

  1. Block JavaScript in uMatrix completely. Rule: * * script block
  2. Create the following local html file:
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <!-- Do not specify character encoding <meta charset="UTF-8"> -->
            <title>Test</title>
        </head>
        <body>
            <h1>Is JavaScript being executed?</h1>
            <h1 id='answer'>No, it is not.</h1>
            <script>document.getElementById('answer').innerText = 'Yes, it is.'</script>
        </body>
    </html>
  3. Open the local html file in Firefox (file://pathToFile/test.html).
  4. Reload page (F5).
  5. Blocking does not work and JavaScript is being executed.

Ruleset

Default + * * script block

Supporting evidence

supporting_evidence

Your environment

  • uMatrix version: 1.4.0
  • Browser Name and version: Firefox 77.0.1
  • Operating System and version: Ubuntu 18.04 LTS
@gorhill
Copy link
Member

gorhill commented Jun 10, 2020

I can reproduce.

It's not even about the character encoding, just having an empty meta tag causes the CSP directive to take effect. This looks like a Firefox issue to me, whether the CSP directive takes effect or not should not depend on the existence of another meta tag.

@uBlock-user uBlock-user added the something to address something to address label Jun 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
something to address something to address
Projects
None yet
Development

No branches or pull requests

3 participants