Status Update
Comments
pt...@google.com <pt...@google.com> #2
pt...@google.com <pt...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
bu...@google.com <bu...@google.com> #4
ch...@gmail.com <ch...@gmail.com> #5
I created a small test application with a WebView and a website that downloads a file with the contentDisposition set as mentioned above (
The application downloads this file, but names it "download-file.txt" and does not use the filename specified in the contentDisposition.
bu...@google.com <bu...@google.com>
pb...@google.com <pb...@google.com> #6
Thank you for the test application. I can confirm the issue.
The problem is the parsing of the content-disposition, as implemented by
The immediate issue is that the regular expression fails if it encounters unexpected content, such as filename*
instead of simply ignoring it.
Ideally it should also respect filename*
values. As per the RFC, a filename*
option should be preferred.
be...@google.com <be...@google.com> #7
The filename*
.
I see that
I haven't looked at any of the rest of the spec but it might not only be filename*
that we need to update as part of this.
We should probably treat this as a feature request.
nt...@google.com <nt...@google.com> #8
We discussed this today. Some ideas include:
- We could update the Android framework code for this API (have not determined how difficult this would be). This would fix the issue only for new Android OS versions, however an app developer could copy this open source implementation into their own app.
- We could consider porting the implementation into our
androidx.webkit
library. That would let developers get an updated implementation that works on any OS version. This doesn't necessarily even need to call into chromium code, since it seems the current version of the API is implemented without calling chromium code.
I agree this is best categorized as a feature request.
pb...@google.com <pb...@google.com>
ap...@google.com <ap...@google.com> #9
Branch: androidx-main
commit df6bc29927fe53578c08ed0f23a417281728357a
Author: Peter Birk Pakkenberg <pbirk@google.com>
Date: Tue Dec 05 14:15:20 2023
Add URLUtilCompat class with new implementations
These methods can be used by the android.webkit.DownloadListener interface
to determine the filename suggested by the server.
The methods are an update to android.webkitURLUtil.
Bug: 309927164
Test: Added URLUtilTest.java
Change-Id: Ie4d6a8d0349a8a19c85a15fcb900e947146558d5
A webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/URLUtilCompatTest.java
A webkit/webkit/src/main/java/androidx/webkit/URLUtilCompat.java
pb...@google.com <pb...@google.com> #10
Filed
pb...@google.com <pb...@google.com>
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit 9fcc12508205bcaba61c3fe2a770f3ff6833c88d
Author: Peter Birk Pakkenberg <pbirk@google.com>
Date: Wed Jan 10 11:15:07 2024
Unhide URLUtilCompat
RelNote: """Add compatibility for `URLUtil.guessFileName`. The
compatibility version supports parsing of `Content-Disposition`
headers that use the `filename*` encoded value attribute as defined
in [RFC 6266](
The compatibility API also directly exposes a method to parse the
`Content-Disposition` header where a suggested file name based on
URL and MIME-type is not desired."""
Fixes: 309927164
Test: N/A - unhide API
Change-Id: If6ae780cbb49f2092f22bd796a6eccb34f25e877
M webkit/webkit/api/current.txt
M webkit/webkit/api/restricted_current.txt
M webkit/webkit/src/main/java/androidx/webkit/URLUtilCompat.java
Description
Component used: android.webkit.URLUtil.guess Version used: Android SDK 34 Devices/Android versions reproduced on: Android 13/14 Pixel 4/5
The issue is that the regex matching the contentDisposition to retrieve the filename does not support the "filename*"-directive which allows for a specific encoding. Thus, the following input for contentDisposition is ignored and instead the filename is guessed based on the url: attachment; filename*=UTF-8''Test.png; filename="Test.png"
See here for more information on the Content-Disposition.