Bug 85635 - Exception in [WebFrame loadRequest:] breaks some WebKit apps
Summary: Exception in [WebFrame loadRequest:] breaks some WebKit apps
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh All
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2012-05-04 10:10 PDT by Brady Eidson
Modified: 2012-05-04 10:44 PDT (History)
1 user (show)

See Also:


Attachments
Patch v1 (2.11 KB, patch)
2012-05-04 10:22 PDT, Brady Eidson
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2012-05-04 10:10:57 PDT
Starting in http://trac.webkit.org/changeset/112571 some apps started seeing exceptions in [WebFrame loadRequest:] 

The exception is -[NSURL initFileURLWithPath:]: nil string parameter

Some API clients incorrectly use full paths instead of actual file: URLs so r112571 started assuming all invalid URLs might "path as URL" attempts and tried rewriting them.

Other WebKit clients use loadRequest: with a nil NSURLRequest, or with a request that has a nil NSURL.  These URLs are invalid, therefore we started trying to rewrite them, therefore we got the exception.

To continue supporting such clients, we should only rewrite invalid URLs that are also non-null.

In radar as <rdar://problem/11312853>
Comment 1 Brady Eidson 2012-05-04 10:22:17 PDT
Created attachment 140264 [details]
Patch v1
Comment 2 Alexey Proskuryakov 2012-05-04 10:24:17 PDT
Comment on attachment 140264 [details]
Patch v1

r=me, however I have a sinking feeling that the same issue may be present in other code I added for the same reason.
Comment 3 Brady Eidson 2012-05-04 10:38:06 PDT
(In reply to comment #2)
> (From update of attachment 140264 [details])
> r=me, however I have a sinking feeling that the same issue may be present in other code I added for the same reason.

Auditing the sites you changed in 112571 and 107355:
[WebView setMainFrameURL:] was changed to use [NSURL _web_URLWithDataAsString:] on the passed in URL string.  If the URL string is nil, [NSURL _web_URLWithDataAsString] already does the right thing.

[WebFrame loadHTMLString:baseURL:] and
[WebFrame loadAlternateHTMLString:baseURL:forUnreachableURL:] and
[WebFrame loadData:MIMEType:textEncodingName:baseURL:]

...were all changed to use [NSURL _webkit_URLFromURLOrPath] on the passed in URLs.  So if those URLs are nil, [NSURL _webkit_URLFromURLOrPath] will also return nil.

So the case I fixed here was the only one that needed fixing.
Comment 4 Brady Eidson 2012-05-04 10:44:29 PDT
Fixed in http://trac.webkit.org/changeset/116124