Open Bug 1523213 Opened 7 years ago Updated 3 years ago

FF still tries to render PDF from 403 response instead of showing response error

Categories

(Core :: DOM: Navigation, defect, P3)

64 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: 13hurdw, Unassigned)

References

()

Details

Attachments

(2 files)

To reproduce:
Request a PDF URL that gives a 403 response

Expected:
Response handled, response content or response error page shown to user.

Actual:
FF still tries to render PDF, which doesn't work because content is either none or non-PDF.

Component: PDF Viewer → Networking: HTTP
Product: Firefox → Core

Why Net:HTTP? This seems to be issue with the PDF viewer or how content sniffing is setup..

Flags: needinfo?(bugzilla)

The weird thing I can see is "mimeType": "application/pdf" in the HAR. This means a sniffer or a guess from the extension.

Isn't the unknown content decoder lining in networking ?
I moved the bug based on that assumption.

The response is without content-type header (violation of http 1.1 rfc) according to https://websniffer.cc/?url=https://dl.humble.com/ops/pdfs/wavesandforms_preview.pdf and there is no content in the response (Content-Length:0 ) which let me believe that the unknown content decoder seem to use the pdf extension for the detection.

The detection fails here and not the consumer (pdf.js) but I'm not sure why the unknown content decoder is called on a 403.

Flags: needinfo?(bugzilla)

I do not know C++ but this looks like the place where it tries to guess based on the request URL
https://searchfox.org/mozilla-central/source/netwerk/streamconv/converters/nsUnknownDecoder.cpp#482

I think we end up here, yes:
https://searchfox.org/mozilla-central/rev/5c8ea961d04767db723a0a15e3a8f7fbca154129/uriloader/exthandler/nsExternalHelperAppService.cpp#2577

Anyway, this is for a more broad discussion. We want to render/handle 403 (and number of other error pages, like 401/7, 500, 301[2] etc) and show the content. And when c-t is missing we want to sniff.

So I kinda tend to resolve this as INVALID as all the indices show the response is a PDF. I still think this should be handled in the PDF viewer and gracefully fallback to some "this PDF is broken" message. I don't think we can handle this on the Necko level well to satisfy all possible scenarios.

Adding Dragana for thoughts.

Priority: -- → P3
Whiteboard: [necko-triaged]

Actually, I don't see this as a networking bug.

Dragana, please see comment 6.

Component: Networking: HTTP → PDF Viewer
Flags: needinfo?(dd.mozilla)
Priority: P3 → --
Product: Core → Firefox
Whiteboard: [necko-triaged]

pdf viewer do have an info that the pdf cannot be rendered.

This is a broader discussion about error pages. We render network errors but not 403, 401...
I will move this to docshell because rendering will be there.

In case we decide to render such error pages we should disable sniffing by the extension for error codes.

Component: PDF Viewer → Document Navigation
Flags: needinfo?(dd.mozilla)
Product: Firefox → Core
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: