Bug 169060 - [WK2][!NETWORK_SESSION] Failure to download when using a download attribute with no value on an anchor
Summary: [WK2][!NETWORK_SESSION] Failure to download when using a download attribute w...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-03-01 14:38 PST by Chris Dumez
Modified: 2017-03-01 16:27 PST (History)
9 users (show)

See Also:


Attachments
Patch (4.47 KB, patch)
2017-03-01 14:49 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (6.15 KB, patch)
2017-03-01 15:31 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (9.79 KB, patch)
2017-03-01 16:00 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2017-03-01 14:38:27 PST
Failure to download when using a download attribute with no value on an anchor.
Comment 1 Chris Dumez 2017-03-01 14:38:56 PST
<rdar://problem/30773140>
Comment 2 Chris Dumez 2017-03-01 14:49:31 PST
Created attachment 303127 [details]
Patch
Comment 3 Darin Adler 2017-03-01 15:00:58 PST
Comment on attachment 303127 [details]
Patch

What about a download attribute with a value that consists entirely of whitespace? Many properties like this one strip leading and trailing HTML spaces; does this one do that?
Comment 4 Darin Adler 2017-03-01 15:01:22 PST
Comment on attachment 303127 [details]
Patch

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

> Source/WebKit2/ChangeLog:11
> +        up passing an empty string as suggested filename to Safari which is ot handled properly.

ot -> not
Comment 5 Darin Adler 2017-03-01 15:02:03 PST
Comment on attachment 303127 [details]
Patch

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

> Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp:204
> +    String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(m_suggestedFilename.isEmpty() ? filename : m_suggestedFilename, mimeType);

Might also want to change the code so it never sets m_suggestedFilename to an empty string.
Comment 6 Chris Dumez 2017-03-01 15:07:53 PST
(In reply to comment #3)
> Comment on attachment 303127 [details]
> Patch
> 
> What about a download attribute with a value that consists entirely of
> whitespace? Many properties like this one strip leading and trailing HTML
> spaces; does this one do that?

We do not strip spaces:
- Safari: creates a file with only whitespaces in the name
- Firefox: creates a file with only whitespaces in the name
- Chrome: creates a file with name "-  -.jpeg" (i.e. sanitizes so first and last character cannot be whitespace)
Comment 7 Chris Dumez 2017-03-01 15:31:39 PST
Created attachment 303133 [details]
Patch
Comment 8 Chris Dumez 2017-03-01 15:32:54 PST
(In reply to comment #5)
> Comment on attachment 303127 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=303127&action=review
> 
> > Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp:204
> > +    String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(m_suggestedFilename.isEmpty() ? filename : m_suggestedFilename, mimeType);
> 
> Might also want to change the code so it never sets m_suggestedFilename to
> an empty string.

Done in the latest iteration. Requesting review again because of this extra change.
Comment 9 Chris Dumez 2017-03-01 16:00:36 PST
Created attachment 303139 [details]
Patch
Comment 10 Chris Dumez 2017-03-01 16:27:24 PST
Comment on attachment 303139 [details]
Patch

Clearing flags on attachment: 303139

Committed r213253: <http://trac.webkit.org/changeset/213253>
Comment 11 Chris Dumez 2017-03-01 16:27:31 PST
All reviewed patches have been landed.  Closing bug.