Skip to content

[Windows] Fix TestURL.swift crash #2413

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

Merged

Conversation

gmittert
Copy link
Contributor

On Windows, | is a valid character in a URL (as a replacement to :,
e.g. /C|/Users/gwenm. This causes a test testing
http://test.com/unescaped|pipe which is expected to not parse to
parse successfully on Windows. The test then tries to parse the <null url> in the expected result and crashes.

This changes the test to check to make sure it can parse the expected
result instead of force casting so that the test fails instead of
crashing.

This allows TestURL to run to completion in the mean time while working
on URL for Windows.

On Windows, `|` is a valid character in a URL (as a replacement to `:`,
e.g. `/C|/Users/gwenm`. This causes a test testing
`http://test.com/unescaped|pipe` which is expected  to not parse to
parse successfully on Windows. The test then tries to parse the `<null
url>` in the expected result and crashes.

This changes the test to check to make sure it can parse the expected
result instead of force casting so that the test fails instead of
crashing.

This allows TestURL to run to completion in the mean time while working
on URL for Windows.
@gmittert gmittert requested a review from compnerd July 13, 2019 00:04
@gmittert
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor

I need to look closely at this — if | is not allowed in a URL path, that doesn't change between platforms.

@millenomi
Copy link
Contributor

@gmittert Why is URL parsing different on Windows?

@millenomi
Copy link
Contributor

(URL parsing is anchored to a standard; what is the use case for deviating for it? Am I missing something re: it being already the case in CF?)

@gmittert
Copy link
Contributor Author

gmittert commented Jul 15, 2019

re: it being already the case in CF?

Exactly, it's already accepted in CF on Windows: https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURL.c#L1980 but the tests don't handle that case.

From the Standard: https://tools.ietf.org/html/rfc8089#appendix-E.2.2

   Historically, some usages of file URIs have included a vertical line
   character "|" instead of a colon ":" in the drive letter construct.
   [RFC3986] forbids the use of the vertical line; however, it may be
   necessary to interpret or update old URIs.
...
 This is intended to support regular DOS or Windows file URIs with
   vertical line characters in the drive letter construct.  For example:

   o  "file:///c|/path/to/file"

@millenomi
Copy link
Contributor

Approved.

@millenomi millenomi merged commit e29e701 into swiftlang:master Jul 17, 2019
@gmittert gmittert deleted the ParsedPipesPainfullyPauseProgress branch July 17, 2019 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants