GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Bug] Setting the wrong user @match prevents opening the menu · Issue #3171 · greasemonkey/greasemonkey

[Bug] Setting the wrong user @match prevents opening the menu #3171

New issue
Copy link
New issue
Copy link
Closed
Closed
[Bug] Setting the wrong user @match prevents opening the menu#3171
Copy link
Milestone
4.12

Description

@esperecyan
esperecyan
opened on Oct 31, 2023
Issue body actions

If the incorrect syntax “user@match” is set, then the Greasemonkey menu will not open at all.

It is still possible to recover from this situation, as Greasemonkey menus can still be opened in about:addons and so on.

Error: @match: Invalid host specified. MatchPattern.js:81:11

greasemonkey/third-party/MatchPattern.js

Lines 80 to 82 in 11e340b

if (!REG_HOST.test(host)) {
throw new Error("@match: Invalid host specified.");
}

Activity

  1. arantius commented on Nov 2, 2023

    @arantius
    arantius
    on Nov 2, 2023
    Collaborator
    More actions

    Confirmed. This comes from inside monkey-menu.js in the loadScripts() function, when checking whether the script runs on the current page.

  2. arantius commented on Nov 3, 2023

    @arantius
    arantius
    on Nov 3, 2023
    Collaborator
    More actions

    For a bit more detail: This bug comes through

    greasemonkey/src/browser/monkey-menu.js

    Line 331 in 11e340b

    function loadScripts(userScriptsDetail, url) {
    calling

    greasemonkey/src/user-script-obj.js

    Line 149 in 11e340b

    runsOn(url) {
    on each script, which relies on

    greasemonkey/src/user-script-obj.js

    Line 173 in 11e340b

    _testCludes(url) {
    .

    If this last helper, _testCludes() finds a match from includes, excludes, or any match before the invalid user match nothing happens. (This is effectively the workaround, except that comes from runsOn() and causes it to never call the helper at all.) If none of these cases occur, we get to the bottom of _testCludes() which involves attempting to parse the (user) match string into a match object, which previously failed and was uncaught. Any invalid user match, not just the literal user@match will trigger this failure, if the code gets this far.

    Reacted by 100の人 (エスパー・イーシア)
    Reacted by 100の人 (エスパー・イーシア)
  3. arantius
    closed this as completedin eac5832on Nov 3, 2023
  4. arantius commented on Nov 5, 2023

    @arantius
    arantius
    on Nov 5, 2023
    Collaborator
    More actions

    I've checked with the above commit that adding a bad match in the script editor still gives an error, and installing a script with a bad match (e.g. https://gist.github.com/arantius/d8fadc5affd40fa5acdff34925189965 ) still gives an error, as desired in both cases.

    Reacted by 100の人 (エスパー・イーシア)
  5. arantius
    added this to the 4.12 milestone on Nov 8, 2023
  6. arantius commented on Nov 29, 2023

    @arantius
    arantius
    on Nov 29, 2023
    Collaborator
    More actions

    This should be done. I could use your help testing this! Checkout or download Greasemonkey's source code, then follow the documentation for installing an extension during development. As far as I know this will break installed scripts, so you should use about:profiles to create and launch a new blank Firefox profile to do so, rather than overwriting your existing Greasemonkey install. (Maybe take a Greasemonkey backup first to be safe.)

    Any testing results, positive or negative, would be great.

  7. esperecyan commented on Nov 29, 2023

    @esperecyan
    esperecyan
    on Nov 29, 2023
    ContributorAuthor
    More actions

    Thanks for the fix! I was able to confirm that can open the menu with the incorrect user @match by testing the following steps.

    1. In Greasemonkey 4.11, adds https://*example.com/* to user @match.
    2. Confirmed that the menu no longer opens.
    3. Installs 8bd283f.
    4. Confirmed that can open the menu and can remove incorrect @match.
  8. Zombie10
    added a commit that references this issue on Nov 24, 2024

    Catch exceptions in `_testMatch()`.

    This issue will close once commit eac5832 is merged into the 'master' branch.
    eac5832
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      • 4.12

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.