Bug 261164 - Safari adds .txt extension when downloading files
Summary: Safari adds .txt extension when downloading files
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-09-05 09:57 PDT by fivoya9380
Modified: 2023-09-12 09:58 PDT (History)
2 users (show)

See Also:


Attachments
Save dialog (35.26 KB, image/png)
2023-09-05 09:57 PDT, fivoya9380
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description fivoya9380 2023-09-05 09:57:10 PDT
Created attachment 467556 [details]
Save dialog

Steps to reproduce:
1. Download https://raw.githubusercontent.com/AnubisNekhet/AnuPpuccin/main/snippets/extended-colorschemes.css
2. In the download popup, Safari adds .txt to the file name
Comment 1 Alexey Proskuryakov 2023-09-05 11:33:32 PDT
Steps to reproduce: Option-click on the link above.

I think that this is correct behavior. GitHub doesn't provide Content-Disposition, so we don't have a download name at all - we just have the URL, which could be quite misleading - e.g. this very Bugzilla page has an URL that looks as if it were a "show_bug.cgi" file, but it's actually HTML is one were to download it.

So given that the only thing we actually know about the downloaded file is that it's text/plain, adding .txt to make sure that it opens in a text editor is best.

$ curl -I https://raw.githubusercontent.com/AnubisNekhet/AnuPpuccin/main/snippets/extended-colorschemes.css
HTTP/2 200 
cache-control: max-age=300
content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
content-type: text/plain; charset=utf-8
etag: "612064a4fab9584daceda780b8378560f1467a64520bcf4500b6b8fde3b7aa72"
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: deny
x-xss-protection: 1; mode=block
x-github-request-id: 7328:6A88:F78C0:1241D4:64F77388
accept-ranges: bytes
date: Tue, 05 Sep 2023 18:29:29 GMT
via: 1.1 varnish
x-served-by: cache-sjc1000141-SJC
x-cache: MISS
x-cache-hits: 0
x-timer: S1693938569.088852,VS0,VE161
vary: Authorization,Accept-Encoding,Origin
access-control-allow-origin: *
cross-origin-resource-policy: cross-origin
x-fastly-request-id: aeba5e6b25f2d750f137cfdcd0792a30cbe91810
expires: Tue, 05 Sep 2023 18:34:29 GMT
source-age: 0
content-length: 29296
Comment 2 fivoya9380 2023-09-05 11:41:26 PDT
I would rather have Safari support different file extensions for download like css, js, etc and allow downloading them as such, instead of adding .txt extension.


If a file with extension other than the above gets downloaded with content-type: text/plain, in such cases Safari can add .txt.
Comment 3 Radar WebKit Bug Importer 2023-09-12 09:58:14 PDT
<rdar://problem/115366701>