mozilla-mobile / firefox-ios

Firefox for iOS
Mozilla Public License 2.0
12.19k stars 2.92k forks source link

[iPhone] Download prompt is not triggered at redditsave.com #11230

Open softvision-raul-bucata opened 2 years ago

softvision-raul-bucata commented 2 years ago

Steps to reproduce

  1. Navigate to: https://redditsave.com/info?url=https%3A%2F%2Fwww.reddit.com%2Fr%2FMadeMeSmile%2Fcomments%2Fvu2gc2%2Fhockey_player_thinks_his_penalty_is_bullshit%2F
  2. Scroll the page.
  3. Tap on the "Download HD Video" button.
  4. Observe the result.

    Expected behavior

    A download prompt is triggered.

    Actual behavior

    A new window opens, with a broken "Play" button.

    Device & build information

  1. Reproducible regardless of the status of ETP.
  2. Works as expected using the latest build of Edge.
  3. Initially reported here: https://github.com/webcompat/web-bugs/issues/107066

Attachments:

Firefox: Screenshot!UNITO-UNDERSCORE!16

Edge: Screenshot!UNITO-UNDERSCORE!17

┆Issue is synchronized with this Jira Task

gutley commented 2 years ago

FYI this is caused by the following being commented out inside DownloadHelper:

        // Bug 1474339 - Don't auto-download files served with 'Content-Disposition: attachment'
        // Leaving this here for now, but commented out. Checking this HTTP header is
        // what Desktop does should we ever decide to change our minds on this.
        // let contentDisposition = (response as? HTTPURLResponse)?.allHeaderFields["Content-Disposition"] as? String
        // let isAttachment = contentDisposition?.starts(with: "attachment") ?? (mimeType == MIMEType.OctetStream)

        guard isAttachment || !canShowInWebView || forceDownload else {
            return nil
        }

The response does indeed have a contentDisposition starting with "attachment" . Here's the full response:

<NSHTTPURLResponse: 0x292eb9c80> { URL: https://sd.redditsave.com/download.php?permalink=https://reddit.com/r/MadeMeSmile/comments/vu2gc2/hockey_player_thinks_his_penalty_is_bullshit/&video_url=https://v.redd.it/wkvpw0bsy9a91/DASH_720.mp4?source=fallback&audio_url=false } { Status Code: 200, Headers {
    "Alt-Svc" =     (
        "h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400"
    );
    "Cache-Control" =     (
        "must-revalidate, post-check=0, pre-check=0"
    );
    "Content-Disposition" =     (
        "attachment; filename=\"redditsave.com_hockey_player_thinks_his_penalty_is_bullshit-wkvpw0bsy9a91.mp4\""
    );
    "Content-Length" =     (
        3345316
    );
    "Content-Type" =     (
        "application/octet-stream"
    );
    Date =     (
        "Tue, 12 Jul 2022 14:37:23 GMT"
    );
    Expires =     (
        0
    );
    Pragma =     (
        public
    );
    "Report-To" =     (
        "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=Vw3w8QzmzYBTVLZMR63SylMNP1TSbzyQNECPgKYOFbCwcjjRwUUymBUZX4HuwGb%2FEztP3AizGoVxOrVg9OAM9t9ii9NKYJDo%2B7cumQvDzxcFlikBYVU3VkMF9%2BT7V6k0Iix0dQ%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}"
    );
    Server =     (
        cloudflare
    );
    Vary =     (
        "Accept-Encoding"
    );
    "cf-cache-status" =     (
        DYNAMIC
    );
    "cf-ray" =     (
        "729a8421e99c7780-LHR"
    );
    "content-description" =     (
        "File Transfer"
    );
    "content-transfer-encoding" =     (
        Binary
    );
    "expect-ct" =     (
        "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
    );
    nel =     (
        "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}"
    );
} }

and the mimeType is video/mp4

gutley commented 2 years ago

FYI - Safari offers to either view or download the file (it also fails to load if viewed) image

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale. Has the issue been fixed, or does it still require the community's attention? Please leave any comment to keep this issue opened. It will be closed automatically if no further update occurs in the next 30 days. Thank you for your contributions!

gutley commented 1 year ago

This issue still happens as we still do not respect the content disposition header