whatwg / url

URL Standard
https://url.spec.whatwg.org/
Other
526 stars 137 forks source link

Windows drive letter uppercasing #515

Open annevk opened 4 years ago

annevk commented 4 years ago

Chrome uppercases the Windows drive letter (only on Windows) as part of its file URL parsing. No other browser engine, including IE6, IE8, IE10, and IE11, seems to do this. However, there is something to be said for doing this as the letters are supposed to be case-insensitive and we already perform some normalization.

A prerequisite should probably be Chrome successfully shipping this on all platforms.

alwinb commented 4 years ago

I found that IE and Edge actually lowercase the drive letter, and then incorrectly stick it to the host, e.g. file://somehost/C:/test becomes file://somehostc:/test.

Also it seems that Chrome on Mac does not support drive letters at all but treats them as ordinary path components.

annevk commented 4 years ago

FWIW, IE6 at least does not appear to do that (neither lowercasing nor making it part of the host), but I have observed making it part of the host in newer versions, indeed. And yeah, Chrome has a lot of Windows ifdefs unfortunately.

annevk commented 1 year ago

It seems Chromium has at least (partially?) been moving away from this: https://chromium-review.googlesource.com/c/chromium/src/+/2870630.

alwinb commented 1 year ago

How does chromium on windows canonicalise e.g. file:///./C| currently?

The linked discussion mentions:

Currently it only recognises drive letters appearing at the start of the path, optionally after a block of slashes.

That would suggest that it canonicalises to file:///C| which is also not canonical, similar to the problem that this commit tried to solve.

domenic commented 1 year ago

https://jsdom.github.io/whatwg-url/#url=ZmlsZTovLy8uL0N8&base=YWJvdXQ6Ymxhbms= on Chrome on Windows shows it matching the standard, with an output of file:///C: (protocol file:, pathname /C:).

Feeding that output back in is idempotent, so at least that case is not problematic. I'm not sure whether any non-idempotent cases remain, now that https://bugs.chromium.org/p/chromium/issues/detail?id=1083031 is closed.

annevk commented 1 year ago

Given that Chromium essentially reverted this and no other browser has this behavior either, closing this particular issue.

domenic commented 1 year ago

Chromium still uppercases drive letters...

annevk commented 1 year ago

Ah, I misunderstood. I guess it still does it when the drive letter occurs at the start.

alwinb commented 1 year ago

In what situations does it capitalise drive letters? Wouldn’t capitalising drive letters at the start incur the same problem?

There may be another solution that aligns well with chromium’s implementation.

Nb. There are only two test cases in WPT that disagree with that approach.

I don’t think it would be very hard to implement in the standard’s parser, nor in chromium, from what I’ve seen.

However, I do not know how \foo\..\S:\ as a file path is interpreted on windows. If the S: part is interpreted as the drive letter, then it makes sense to do that in the standard as wel.