Bug 196809

Summary: WKNavigationResponse._downloadAttribute should be nil when no download attribute is present
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, commit-queue, darin, david_quesada, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Alex Christensen 2019-04-10 22:35:31 PDT
WKNavigationResponse._downloadAttribute should be nil when no download attribute is present
Comment 1 Alex Christensen 2019-04-10 22:37:14 PDT
Created attachment 367205 [details]
Patch
Comment 2 David Quesada 2019-04-10 22:54:21 PDT
*** Bug 196806 has been marked as a duplicate of this bug. ***
Comment 3 WebKit Commit Bot 2019-04-10 23:16:06 PDT
Comment on attachment 367205 [details]
Patch

Clearing flags on attachment: 367205

Committed r244184: <https://trac.webkit.org/changeset/244184>
Comment 4 WebKit Commit Bot 2019-04-10 23:16:08 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Radar WebKit Bug Importer 2019-04-10 23:17:19 PDT
<rdar://problem/49803597>
Comment 6 Darin Adler 2019-04-11 08:50:40 PDT
Comment on attachment 367205 [details]
Patch

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

> Source/WebKit/UIProcess/API/Cocoa/WKNavigationResponse.mm:84
> -    return _navigationResponse->downloadAttribute();
> +    const String& attribute = _navigationResponse->downloadAttribute();
> +    return attribute.isNull() ? nil : (NSString *)attribute;

The function nsStringNilIfEmpty from WTFString.h was designed for uses like this one. I admit it does not have a beautiful name, but this is exactly what it’s for.
Comment 7 Darin Adler 2019-04-11 08:51:13 PDT
Comment on attachment 367205 [details]
Patch

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

>> Source/WebKit/UIProcess/API/Cocoa/WKNavigationResponse.mm:84
>> +    return attribute.isNull() ? nil : (NSString *)attribute;
> 
> The function nsStringNilIfEmpty from WTFString.h was designed for uses like this one. I admit it does not have a beautiful name, but this is exactly what it’s for.

Oops, no, this is "nil if null", which is not the same thing. Sorry.