Closed Bug 1738190 Opened 4 years ago Closed 3 years ago

"Open Image in New Tab" doesn't work for inlined data: URL images

Categories

(Firefox :: Menus, defect, P3)

Desktop
All
defect

Tracking

()

VERIFIED FIXED
110 Branch
Tracking Status
firefox110 --- verified
firefox111 --- verified

People

(Reporter: glob, Assigned: Gijs)

References

Details

Attachments

(2 files)

Attached file testcase

STR:

  1. create content that has an inline SVG as a background image (see attached)
  2. right click on background --> "Open Image in New Tab"

Expected:

  • Navigated to the background's data: URL

Actual:

  • A blank tab

Very similar to Bug 1658244 but involves opening in a background tab.

  • the "Refresh" button is disabled on the new tab
  • focusing the address bar and hitting Return to navigate to the url results in SVG being correctly shown

Glob: do you know when this regressed? It looks like that menu item still calls viewMeda() which does have forceAllowDataURI: true set (same fix as bug 1658244, but done in an earlier bug).
https://searchfox.org/mozilla-central/source/browser/base/content/nsContextMenu.js#1414

Is this maybe a MR2 change to context menus?

Actual:

  • A blank tab

For me it's a blank tab with the data: url pre-populated in the awesomebar. As a workaround you can just hit enter to load the image. In other cases where we've blocked data: urls I think you don't get the URL showing up because that's the thing that could be phishy

Flags: needinfo?(glob)

Gijs: do you know of any changes to context menus that might have this result?

Flags: needinfo?(gijskruitbosch+bugs)

(In reply to Daniel Veditz [:dveditz] from comment #2)

Gijs: do you know of any changes to context menus that might have this result?

Nothing recent.

(In reply to Daniel Veditz [:dveditz] from comment #1)

It looks like that menu item still calls viewMeda() which does have forceAllowDataURI: true set (same fix as bug 1658244, but done in an earlier bug).
https://searchfox.org/mozilla-central/source/browser/base/content/nsContextMenu.js#1414

The forceAllowDataURI isn't working though, the console reports:

Navigation to toplevel data: URI not allowed (Blocked loading of: “data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUwMCIg...”)

Is this maybe a MR2 change to context menus?

Well, before MR2 there is no "open image in a new tab" item at all, there's only "view background image". So I guess nominally this "broke" with bug 1690030 - but long before that, if you tried middle-clicking or cmd/ctrl-clicking "view background image", that also didn't work. The issue is that the code here: https://searchfox.org/mozilla-central/rev/4f9bbbe5487da6d1c3680488e016f7bb0cbaa128/browser/base/content/utilityOverlay.js#596,616-618 only adds the load flag for images opened in the "current" tab, not for images opened in new tabs. To fix that, we'd need to add a flag to addTab and ensure we pass it from the context menu cases into openLinkIn and friends, through to tabbrowser.

Component: DOM: Security → Menus
Flags: needinfo?(glob)
Flags: needinfo?(gijskruitbosch+bugs)
Product: Core → Firefox

(In reply to Daniel Veditz [:dveditz] from comment #1)

For me it's a blank tab with the data: url pre-populated in the awesomebar. As a workaround you can just hit enter to load the image. In other cases where we've blocked data: urls I think you don't get the URL showing up because that's the thing that could be phishy

I don't know if you want to file some kind of separate bug for this? It's the user opening the URI so I don't think it's bad, but perhaps there are other cases - I dunno off-hand.

Flags: needinfo?(dveditz)

Not a separate bug, I'm just reporting symptoms in case it's a clue. 1) confirming glob's report that the menu is broken (image not shown), but also 2) this is not the behavior I'd expect if we were intentionally blocking the data: url (blank out the address). Maybe this is some kind of in-between state?

Flags: needinfo?(dveditz)
Severity: -- → S4
Priority: -- → P3

I'm still seeing this on Mastodon - STRs are, be on Mastodon.social (logged in) -> right-click the elephant in the lower left, choose "open image in a new tab."

Result is "data:image/svg+xml;utf8,<svg ...." in the URL bar of the new tab and no image.

Depends on: 1806919

I have a fix, just fighting automated tests.

Assignee: nobody → gijskruitbosch+bugs
Status: NEW → ASSIGNED
OS: Unspecified → All
Hardware: Unspecified → Desktop
Summary: "Open Image in New Tab" doesn't work for inlined SVG images → "Open Image in New Tab" doesn't work for inlined data: URL images
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/9b1c21cf3dbf allow opening inline SVG background images in a new tab, r=dao
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch
QA Whiteboard: [qa-110b-p2]

Reproducible on a 2022-12-20 Nightly build on macOS 12 using the STR and testcase from Comment 0.
Verified as fixed on Firefox 110.0b2(build ID: 20230117185909) and Nightly 111.0a1(build ID: 20230118095131) on macOS 12, Windows 10, Ubuntu 22.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-110b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: