Open Bug 1662780 Opened 4 years ago Updated 4 years ago

Opening SVG file types without extension or DTD in Firefox will show the source code instead of the image

Categories

(Firefox :: Downloads Panel, defect, P3)

Desktop
Unspecified
defect

Tracking

()

Tracking Status
firefox80 --- disabled
firefox81 --- affected
firefox82 --- affected

People

(Reporter: rdoghi, Unassigned)

References

(Blocks 1 open bug)

Details

[Affected versions]:
Nightly 81.0b5

[Affected platforms]:
Platforms: Ubuntu, Mac OS

[Preconditions]
Reach about:config and set the following pref: browser.download.viewableInternally.enabledTypes = SVG,XML,PDF,WEBP,AVIF

[Steps to reproduce]:

  1. Launch the Firefox browser and reach https://mime.ty.ax/
  2. From the preBuilt section > "default content-type, no extension" click the SVG link.
  3. From the Open File dialog window select "Open in Firefox" and Click OK

Expected Result:
The image file should be opened in a new tab and it should be properly displayed.

Actual Results:
A new tab opens with the source code of the Image file instead of the actual image.

I think this defect should have an S3 severity.

Unfortunately this happens because the SVG in the example doesn't have a DTD, so Firefox doesn't detect it as XML+SVG, instead displaying it as a plain text document. Though the download has the content type set, this isn't known when loading the from the file:// URL.

This doesn't happen on Windows. When the file is launched we add an extension, which applies any time we do something other than save, but only on Windows.

I think this could be fixed by always (even on non-Windows) adding the extension when aHandleInternally is set, though this wouldn't fix the more general case of launching the file from the download list if it is saved, and I'm wary of messing with the 17 year old decision to only add the ext on Windows.

This is unlikely to be a major issue, I think we can expect that most SVGs have the proper extension. It does further expose an existing lack of SVG detection, though, which would be relatively hard to encounter otherwise. I agree on S3.

Severity: -- → S3
Priority: -- → P3
Summary: Opening SVG file types without extensions in Firefox will show the source code instead of the image → Opening SVG file types without extension or DTD in Firefox will show the source code instead of the image
See Also: → 1652520
You need to log in before you can comment on or make changes to this bug.