Fix #363 - domain and subdomain wildcard #364
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
Discovered a bug in #363 in resolving private domains that also have a subdomain wildcard.
Proposal
Describe the new/upated/fixed feature
When a rule is added, we check whether a rule-path to it already exists.
If it does and it is the outermost rule (
[] === $list[$rule]
), we add a special marker which indicates that there is a rule for this part before adding the further path.The choice of the marker is quite random (
?
), but it is based on the characters allowed in urls and what is already used in the list entry format.When resolving the
getPublicSuffixLengthFromSection()
, before terminating when iteratively matching the domain labels comes to a halt (no more labels to match), before checking whether there arehasRemainingRules()
we check for the special marker.When recursing here, the
hasRemainingRules
would always be true, as there is another rule further down the array.I've worked up from adding the special marker for every rule, but that doubled the memory usage from ~2 to ~4MB.
So only adding it, before a new rule is added.
This should always work, due to the right to left sorting.
Backward Incompatible Changes
There should be no BC breaks here.
Targeted release version
6.3.2
I'll verify if i can target older versions.
PR Impact
No API changes
Only the structure of the private rules array is modified slightly.
Fixes a bug
Open issues
to be discussed:
addRule
into static methods for readability