Repository navigation
Correct innards of document.domain - #6510
Conversation
|
@sleevi I'd greatly appreciate if you could review https://whatpr.org/html/6510/origin.html#is-a-registrable-domain-suffix-of-or-is-equal-to. |
sleevi
left a comment
There was a problem hiding this comment.
Sorry, I missed the ping. I think I'm going to need to take a deeper look at this tomorrow, but wanted to send some early feedback. Don't go out of your way if my feedback is junk though - I did just want to get some initial impressions shared.
| <li><p>Assert: <var>originalHost</var>'s <span>public suffix</span>, prefixed by U+002E (.), | ||
| matches the end of <var>hostSuffix</var>.</p></li> | ||
| <!-- It would be cleaner to avoid string manipulation on domains. --> |
There was a problem hiding this comment.
So I'm mostly struggling to reason through this one in the event of holes in the PSL, and trying to figure out if this is assertion or should be a distinctly handled branch (i.e. something that returns false)
The Firefox logic previously discussed does have an ASSERT, but that's because it previously did length checks on the inputs (and fast-failed).
That's not to say this is wrong, but it's twinged enough that I'm going to have to spend more time reasoning through and seeing if I can construct counter-examples.
There was a problem hiding this comment.
I think my contrived example is this, mostly related to potential holes in the PSL.
Let's say the PSL has:
example
bar.foo.example
And we're on baz.bar.foo.example, and the attempt is to document.domain = "foo.example"
My understanding is that:
originalHost==baz.bar.foo.exampleoriginalHost's public suffix ==bar.foo.example(withbaz.bar.foo.examplebeing the registrable domain / PSL + 1)hostSuffix==foo.example(Steps 2/3)hostSuffixis a domain (Step 4.1)hostSuffixwith a prefix is.foo.example, which matches the end oforiginalHost(baz.bar.foo.example) - Step 4.2)hostSuffix!=hostSuffix's public suffix (hostSuffix=foo.example, public suffix =example- Step 4.3)hostSuffixwith a prefix is.foo.example, which matches the end oforiginalHost's public suffix (.foo.examplevsbar.foo.example) - Step 4.3- We trigger the assert - Step 4.4 (
.bar.foo.exampledoes not matchfoo.example)
The string length check would reject this once we determine hostSuffix's public suffix (example) is shorter than originalHost's public suffix (bar.foo.example)
Have I screwed up my analysis?
There was a problem hiding this comment.
In your example, in step 4.3, .foo.example matching the end of bar.foo.example is grounds for that step returning false. And therefore it never reaches the assert. (Also, these holes are demonstrated in the examples through *.compute.amazonaws.com.)
There was a problem hiding this comment.
Thanks, I clearly can’t read. You’re entirely right that the check would catch any of the length shenanigans. It feels a little weird that the algorithm doesn’t make that obvious; that is, it’s hard to reason existing implementations are correct and satisfy the “equivalent implementation”, but this algorithm does seem to yield the right/intended result.
There was a problem hiding this comment.
An equivalent conditional we could use that might make the issue of holes more apparent:
hostSuffix's public suffix is not equal to originalHost's public suffix
I suppose I could also embrace the length check, it just seems so icky.
|
Maybe that’s what I’m missing: why is it icky? Because of IDNs and
codepoints?
To be clear, I’m not without my biases. Just because I got confused doesn’t
mean others will, so I’m definitely fine with it as is. I just don’t fully
understand the reasoning for why, but that’s definitely secondary to
getting this fixed, which your change does.
|
|
Mainly because the logical smaller unit is domain labels and this completely side-passes them. We don't have domain labels as a primitive, but they have come up a few times and at some point we might. I could see the other string comparisons being done in terms of domain labels, but the length-based one won't work, except if you phrase it as done here (or compare their public suffixes). |
|
@domenic okay to land this? Not clear this can be tested. |
|
Yep, go ahead and land indeed. And yeah I don't think it's testable using WPTs. We'll have to write our own tests for https://bugs.chromium.org/p/chromium/issues/detail?id=1189861 |
The "public suffix" check needs to done in both directions. This follows a spec clarification linked below. Also add spec examples to our unit tests. Also, drive-by fix for PermissiveGetHostRegistryLength returning string::npos. This change should not have any effect on extensions behaviour, or the URL pattern implementation in particular. Spec: whatwg/html#6510 Bug: 1189861 Change-Id: I5f45464fd7170bfd46ca2c61a0931c7db5e9aabc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3284831 Commit-Queue: Daniel Vogelheim <[email protected]> Reviewed-by: Takashi Toyoshima <[email protected]> Cr-Commit-Position: refs/heads/main@{#945434}
This fixes a regression introduced in 326c644.
(Unclear to me at the moment if it also tackles cases not addressed there and if some of these steps are redundant so this needs more investigation.)
Fixes #6509.
(See WHATWG Working Mode: Changes for more details.)
/infrastructure.html ( diff )
/origin.html ( diff )