Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Fix invalid ruleset scope typings - #20046

Merged
Hainish merged 7 commits into
EFForg:masterfrom
cschanaj:fix-invalid-default-scope-for-custom-ruleset
Apr 14, 2021
Merged

Hainish merged 7 commits into
EFForg:masterfrom
cschanaj:fix-invalid-default-scope-for-custom-ruleset

Conversation

@cschanaj

@cschanaj cschanaj commented Apr 13, 2021 •

Copy link
Copy Markdown
Collaborator

This PR makes compiling scope into RegExp automatic. Pass the string literal version of the scope parameter everywhere, except for when constructing rulesets/ WASM calls.

  • getScope expected a required string parameter, but get none. It is also called multiple time when passed to addFromJson

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring existing code
  • New Ruleset
  • Existing Ruleset

@cschanaj cschanaj added the bug label Apr 13, 2021
@cschanaj cschanaj changed the title Fix invalid ruleset scope for custom rulesets Fix invalid ruleset scope calls Apr 13, 2021
@cschanaj
cschanaj requested review from Hainish and zoracon April 13, 2021 01:44
@cschanaj cschanaj changed the title Fix invalid ruleset scope calls Fix invalid ruleset scope typings Apr 13, 2021
@cschanaj
cschanaj marked this pull request as ready for review April 13, 2021 01:46
Comment thread chromium/background-scripts/rules.js Outdated
settings.enableMixedRulesets,
this.ruleActiveStates,
scope);
getScope(scope));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why change this string to a scope in JavaScript? The scope will be cached when passed to Rust at any rate. It looks like this passes a RegExp to the Rust bindings, which it isn't expecting.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Look like a mistake made when I was trying to figure out the types of scope in different calls. The original source code uses string scope too. It should be a string. Changes made in f87434f

As the getScope function is being called in Ruleset constructor exclusively, I added 1c20e82 to reflect this. Only the internal representation of the scope is a RegExp now. Thanks.

@Hainish Hainish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comment

@cschanaj
cschanaj requested a review from Hainish April 14, 2021 08:05
@Hainish
Hainish merged commit 9762ad8 into EFForg:master Apr 14, 2021
@Hainish

Hainish commented Apr 14, 2021

Copy link
Copy Markdown
Member

LGTM, thanks!

@cschanaj
cschanaj deleted the fix-invalid-default-scope-for-custom-ruleset branch May 29, 2021 23:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants