Bug 205462 - Fetch: handle empty Location value
Summary: Fetch: handle empty Location value
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-12-19 11:39 PST by Rob Buis
Modified: 2019-12-20 08:02 PST (History)
8 users (show)

See Also:


Attachments
Patch (5.52 KB, patch)
2019-12-19 11:44 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (5.90 KB, patch)
2019-12-20 04:21 PST, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Buis 2019-12-19 11:39:57 PST
Handle empty Location value.
Comment 1 Rob Buis 2019-12-19 11:44:58 PST
Created attachment 386126 [details]
Patch
Comment 2 youenn fablet 2019-12-20 03:29:01 PST
Comment on attachment 386126 [details]
Patch

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

> Source/WebCore/loader/SubresourceLoader.cpp:405
> +        if (options().redirect == FetchOptions::Redirect::Follow && response.isRedirection()) {

response.isRedirection() is not needed here.

> Source/WebCore/loader/SubresourceLoader.cpp:406
> +            if (response.httpHeaderFields().contains(HTTPHeaderName::Location) && response.httpHeaderField(HTTPHeaderName::Location).isEmpty()) {

Can we just have one check with something like !isNull() && isEmpty(). or impl() && impl()->isEmpty() maybe?

> Source/WebCore/loader/SubresourceLoader.cpp:410
> +            }

Would be nice if we could do something like:
if (options().redirect == FetchOptions::Redirect::Follow && isLocationURLFailure(response)) {
    ...
    return;
}
Comment 3 Rob Buis 2019-12-20 04:21:46 PST
Created attachment 386200 [details]
Patch
Comment 4 Rob Buis 2019-12-20 04:50:20 PST
Comment on attachment 386126 [details]
Patch

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

>> Source/WebCore/loader/SubresourceLoader.cpp:405
>> +        if (options().redirect == FetchOptions::Redirect::Follow && response.isRedirection()) {
> 
> response.isRedirection() is not needed here.

Ouch! Should have seen that, fixed.

>> Source/WebCore/loader/SubresourceLoader.cpp:406
>> +            if (response.httpHeaderFields().contains(HTTPHeaderName::Location) && response.httpHeaderField(HTTPHeaderName::Location).isEmpty()) {
> 
> Can we just have one check with something like !isNull() && isEmpty(). or impl() && impl()->isEmpty() maybe?

Yes, the former, I think it just uses the latter, but best to stick with the public API (even though StringImpl is not likely to change).

>> Source/WebCore/loader/SubresourceLoader.cpp:410
>> +            }
> 
> Would be nice if we could do something like:
> if (options().redirect == FetchOptions::Redirect::Follow && isLocationURLFailure(response)) {
>     ...
>     return;
> }

Done.
Comment 5 WebKit Commit Bot 2019-12-20 05:35:26 PST
Comment on attachment 386200 [details]
Patch

Clearing flags on attachment: 386200

Committed r253814: <https://trac.webkit.org/changeset/253814>
Comment 6 WebKit Commit Bot 2019-12-20 05:35:28 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2019-12-20 05:36:18 PST
<rdar://problem/58111194>