Bug 71342 - [Mac] _drt_descriptionSuitableForTestResult generate an exception for absolute paths above the main frame
Summary: [Mac] _drt_descriptionSuitableForTestResult generate an exception for absolut...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-01 17:29 PDT by Benjamin Poulain
Modified: 2011-11-01 19:08 PDT (History)
3 users (show)

See Also:


Attachments
Patch (4.22 KB, patch)
2011-11-01 17:41 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2011-11-01 17:29:09 PDT
The test webarchive/loading/test-loading-archive-subresource-null-mimetype.html introduce the first case where a subresource is loaded from outside the test directory.

The file in question file:///test.png causes the method to raise a NSRangeException. This is hidden by the fact that OS X WebKit catch any exceptions when calling the delegate.
Comment 1 Benjamin Poulain 2011-11-01 17:41:17 PDT
Created attachment 113266 [details]
Patch
Comment 2 Darin Adler 2011-11-01 17:48:30 PDT
Comment on attachment 113266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=113266&action=review

> LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt:12
> +file:///test.png - didReceiveResponse <NSURLResponse file:///Users/pecoraro/Desktop/test.png, http status code 0>

That's not good. It has the patch of a user’s home directory!
Comment 3 Darin Adler 2011-11-01 17:50:07 PDT
Comment on attachment 113266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=113266&action=review

>> LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt:12
>> +file:///test.png - didReceiveResponse <NSURLResponse file:///Users/pecoraro/Desktop/test.png, http status code 0>
> 
> That's not good. It has the patch of a user’s home directory!

The path of a specific users’s home directory. We can}t have that in expected test results.
Comment 4 Benjamin Poulain 2011-11-01 17:58:04 PDT
My user directly is definitely not /Users/pecoraro/ :)

This the path of the source as encoded in the webarchive.
Comment 5 Benjamin Poulain 2011-11-01 17:58:37 PDT
s/user directly/user directory
Comment 6 Darin Adler 2011-11-01 18:24:08 PDT
(In reply to comment #4)
> This the path of the source as encoded in the webarchive.

OK, makes sense. I looked in the web archive and couldn’t find that, but it was because it was in the Base64-encoded WebResourceResponse data.
Comment 7 Darin Adler 2011-11-01 18:26:53 PDT
Comment on attachment 113266 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=113266&action=review

> Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm:89
> +    if ([[self path] hasPrefix:basePath]) {
> +        ASSERT([[self path] length] >= ([basePath length] + 1));
> +        return [[self path] substringFromIndex:[basePath length] + 1];
> +    }

We could also write this code so that it appends a "/" to basePath first, then we would not need the assertion or the "+ 1".
Comment 8 Joseph Pecoraro 2011-11-01 18:33:05 PDT
(In reply to comment #4)
> My user directly is definitely not /Users/pecoraro/ :)
> 
> This the path of the source as encoded in the webarchive.

Feel free to update the webarchive. I didn't know this data was inside it,
otherwise I wouldn't have included it originally =(.
Comment 9 WebKit Review Bot 2011-11-01 19:08:33 PDT
Comment on attachment 113266 [details]
Patch

Clearing flags on attachment: 113266

Committed r99031: <http://trac.webkit.org/changeset/99031>
Comment 10 WebKit Review Bot 2011-11-01 19:08:38 PDT
All reviewed patches have been landed.  Closing bug.