Bug 11051 - Javascript Image.src fails to request new image when the url domain contains uppercase letters.
Summary: Javascript Image.src fails to request new image when the url domain contains ...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Major
Assignee: Nobody
URL:
Keywords: HasReduction, InRadar
Depends on:
Blocks:
 
Reported: 2006-09-26 16:18 PDT by Trent Davies
Modified: 2024-04-10 08:46 PDT (History)
3 users (show)

See Also:


Attachments
A reduction test (in HTML) that illustrates the uppercase image request problem. (1.34 KB, text/html)
2006-09-26 16:21 PDT, Trent Davies
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trent Davies 2006-09-26 16:18:47 PDT
im = new Image(); im.src = my_url;

The above javascript code in certain conditions fails to perform an HTTP GET when my_url is set to a domain with uppercase letters in it, as in 'http://www.apPle.com' instead of 'http://www.apple.com'.

This problem occurs in the onclick handler for a link that exits the current page.

**The problem DOES NOT occur when my_url is all lowercase (i.e. 'http://www.apple.com'.**

I will attach a simple reduction test case to illustrate the problem.
Comment 1 Trent Davies 2006-09-26 16:21:06 PDT
Created attachment 10787 [details]
A reduction test (in HTML) that illustrates the uppercase image request problem.
Comment 2 Trent Davies 2006-09-27 08:22:32 PDT
I should clarify that this occurs for any number of uppercase letters in the domain name. APPLE.com and apple.COM both fail. 
Comment 3 Mark Malone 2006-09-27 16:24:54 PDT
rdar://4754309
Comment 4 Alexey Proskuryakov 2006-09-29 10:51:15 PDT
I can reproduce the described behavior, and I think I have an idea about what's going on here, but I'm not sure if this is a bug. Here is the sequence of events in case 4 (uppercase domain, return false):

1) im.src is set, causing an NSURLRequest to be immediately created.
2) The "while (e.getTime()-b.getTime()<500)" loop begins, halting WebKit. NSURLConnection still works on a separate thread, but it cannot call back to WebKit yet.
3) The loop ends, and NSURLConnection finally dispatches connection:willSendRequest:redirectResponse: for the proper domain (apple.com), asking WebKit whether it's fine to proceed with this new domain. WebKit agrees to proceed.
4) NSURLConnection dispatches an HTTP request to apple.com (which actually results in one more connection:willSendRequest:redirectResponse:, because apple.com redirects to www.apple.com).

However, if the onclick handler doesn't prevent leaving the page, then the request is cancelled after step 2, because the frame is destroyed.

Some things we could theoretically do differently:
1) I'm not sure why NSURLConnection needs to ask after it normalizes the (case-insensitive) host name, and why this has to be done asynchronously;
2) perhaps outstanding requests shouldn't be just cancelled when destroying the frame, and we should at least let them be sent.
Comment 5 Ahmad Saleem 2024-04-10 08:46:59 PDT
Safari works fine on this test: First two navigate while last two don't.