Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement origin domain matching #68

Merged
merged 17 commits into from
Aug 14, 2022
Merged

Implement origin domain matching #68

merged 17 commits into from
Aug 14, 2022

Conversation

airtower-luna
Copy link
Owner

@airtower-luna airtower-luna commented Aug 13, 2022

Origin matching allows users to let rules apply only to requests originating from certain domains. The origin is the domain that would appear in an unmodified Referer.

The rule to apply is selected based on the length of matches in the target and origin domains as follows:

  • Prefer the rule with the longest match for the target domain (as before)
  • Among rules with the same length of target match use the rule with the longest origin domain match

Every rule must have a target domain, the origin domain is optional (origin match length is zero if missing).

Closes #15, closes #12.

airtower-luna and others added 11 commits August 12, 2022 23:44
It doesn't do anything yet, but save/restore works.
Required for ESLint to recognize private fields.
That's the oldest version to support private class fields according to
MDN. 91 is on the way out as ESR, so no-one should be running anything
older anyway.
The key part is the RuleMatch.better() method, which encapsulates the
decision which match is better. That will make it easier to modify the
rule system going forward.
Thanks for the suggestion, Crystal!

Co-authored-by: Crystal Cat <58235142+crystal-cat@users.noreply.github.com>
The rule to apply is selected as follows:

* Use the rule with the longest match for the target domain
* Among rules with the same target domain match use the rule with the
  longst origin domain match

Every rule *must* have a target domain, the origin domain is optional
(match length is zero if missing).
The value for "target" was missing, leading to those for later fields
shifting.
@airtower-luna airtower-luna added the enhancement New feature or request label Aug 13, 2022
@airtower-luna airtower-luna added this to the 1.0 milestone Aug 13, 2022
@airtower-luna airtower-luna self-assigned this Aug 13, 2022
@Gitoffthelawn
Copy link
Contributor

Are you able to upload a beta version to AMO? AFAIK, only users intentionally installing a beta version on AMO will get it. Of course, you may want to confirm my AFAIK first!

@airtower-luna
Copy link
Owner Author

I had the same thought yesterday and checked. 😸 Unfortunately it looks like AMO removed the beta channel option: https://extensionworkshop.com/documentation/publish/distribute-pre-release-versions/

What I could do is get a beta version signed for self-distribution and offer it through a pre-release here, with the catch that you'd have to manually update to further beta versions. Well, unless I also set up my own update manifest, too, but that's additional maintenance effort and if I forget to remove it before release that'd be bad. 😅

@Gitoffthelawn
Copy link
Contributor

Ah, now that you mention it, I am recalling that they made that change. 😸

Another option (and one I would personally prefer), is to publish another extension called "Referer Modifier BETA" on AMO. I've seen a few other extensions do this, and it seems to be a good workaround. I can write the blurb (description) for the beta version, if that helps you.

Purely negative regular expressions like (?<!\.?y\.test)$ (for any
domain that isn't y.test or its subdomain) result in a zero length
match, and should have priority over rules with no origin match at
all.
It ends up in the console on every website load, which is a bit
much. Keep the concept around as Rule.toString() so it's easily
available if needed.
@airtower-luna
Copy link
Owner Author

A separate beta extension seems like a lot more trouble, both for me and people who want to test: It'd need a separate add-on ID, configuration wouldn't carry over automatically, and beta users would never automatically switch back to release, which means I'd have to maintain it indefinitely. I think I'll use self-distributed beta releases as needed, and set up an update manifest if it looks like there'll be many. Which I don't expect. 😅

Anyway, a beta release won't happen until I merge this, which should be very soon. 🙂

@airtower-luna airtower-luna marked this pull request as ready for review August 14, 2022 14:39
@airtower-luna airtower-luna merged commit 0bb31c9 into main Aug 14, 2022
@airtower-luna
Copy link
Owner Author

@wvxwxvw, if you'd like to update the RU localization before I release 1.0 let me know and I'll create an issue listing the messages that changed. If not that's fine too, no pressure. 🙂

@airtower-luna airtower-luna deleted the origin-match branch August 14, 2022 15:21
@airtower-luna
Copy link
Owner Author

@wvxwxvw
Copy link
Contributor

wvxwxvw commented Aug 15, 2022

@airtower-luna
I'll compare it myself.

Copy link

@LqhResearch LqhResearch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FR: Allow specifying a source Add an option to override/remove only 3rd-party referrers for sites
5 participants