Bug 160890

Summary: Following redirects to non-punycoded domains
Product: WebKit Reporter: Ruslan Kudubayev <ruslan.kudubayev>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ap, beidson, wilander
Priority: P2    
Version: Safari 9   
Hardware: All   
OS: Unspecified   

Description Ruslan Kudubayev 2016-08-15 20:19:01 PDT
Latest Safari both on iPhone and Mac seem to have an issue with following redirects to urls where the domain is non-punycoded (i.e. using international characters). When same url is pasted into the address bar the dns resolves correctly.

To reproduce, you'd generally need a redirector - it's hard to find one that wouldn't automatically punycode the urls.
I've created a 302 redirect on a cloud machine (redirects to russian domain кто.рф). This does not work on iPhone's Safari and Chrome (works in Google Search App). Works fine on my desktop machine (unix, chrome) and using wget command. On Mac, it doesn't work on Safari, but works in Chrome. So seems like a webkit issue.

Test url: http://104.197.144.181/punycodetest.php - I'll take this down in a few days.
Comment 1 Alexey Proskuryakov 2016-08-15 22:46:49 PDT
$ curl -i http://104.197.144.181/punycodetest.php
HTTP/1.1 302 Moved Temporarily
Date: Tue, 16 Aug 2016 05:44:07 GMT
Server: Apache
X-Powered-By: PHP/5.6.24
X-Frame-Options: SAMEORIGIN
Location: http://кто.рф/eng
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Comment 2 Alexey Proskuryakov 2016-08-15 22:50:01 PDT
Reproduced with shipping Safari on OS X 10.10.5.

The Location field is UTF-8 encoded. I suspect that CFNetwork doesn't support that (and I'm not sure if there is anything spec-like that allows for non-ASCII in HTTP response headers).
Comment 3 Alexey Proskuryakov 2016-08-15 22:51:02 PDT
Seems more like a WebKit issue than a CFNetwork one, because the error page in Safari shows the URL correctly decoded.
Comment 4 Ruslan Kudubayev 2016-08-17 12:26:12 PDT
Thanks for taking a look! Is "Page Loading" still the right component?
Comment 5 Alexey Proskuryakov 2016-08-17 12:34:23 PDT
Probably either this or Platform, depending on where the issue ends up being. It doesn't matter very much once the right people are CC'ed.
Comment 6 Alex Christensen 2016-08-18 09:52:30 PDT
I just verified the following, which leads me to believe that it was something that was fixed in CFNetwork for iOS10 and Sierra.

Works correctly, opening http://кто.рф/eng
    MacOS Sierra, Safari using NSURLSession
    MacOS Sierra, Safari using NSURLConnection
    iOS10, MobileSafari using NSURLSession
    Chrome
    Firefox
    Edge

Works incorrectly, opening "Safari Can't Find the server"
    OSX El Capitan, Shipping Safari
    OSX El Capitan, latest build of WebKit/Safari using NSURLConnection
    OSX El Capitan, latest build of WebKit/Safari using NSURLSession
    iOS8, MobileSafari using CFURLConnection
    iOS9, MobileSafari using CFURLConnection
Comment 7 John Wilander 2016-08-18 10:45:04 PDT
We did fix https://bugs.webkit.org/show_bug.cgi?id=158371 recently although I don't think setHost is involved in HTTP redirects.
Comment 8 Ruslan Kudubayev 2016-08-22 11:20:01 PDT
Thanks! I did also find that iOS beta does not have this issue.
Probably ok to close this issue unless you want to spend more time looking for culprit.
Comment 9 Alex Christensen 2016-08-22 11:22:04 PDT
Fixed, probably by CFNetwork.
Thanks for reporting!  Reports like this often yield improvements in ways we may have overlooked