Open Bug 1825959 Opened 2 years ago Updated 1 year ago

The target "image/jpeg" is not respected when reading from the X11 clipboard

Categories

(Core :: Widget: Gtk, defect, P3)

Firefox 110
defect

Tracking

()

UNCONFIRMED

People

(Reporter: awalgarg, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0

Steps to reproduce:

  1. Place any jpeg file on the X11 selection clipboard.
  2. Example: xclip -selection clipboard -target image/jpeg /path/to/file.jpeg.
  3. Verify that another application is able to read it.
  4. Example: xclip -out -selection clipboard | feh -, displays the copied image.
  5. xclip -out -selection clipboard -target TARGETS, shows image/jpeg.
  6. Paste it in an input element in firefox and inspect the ClipboardEvent consequently dispatched.
  7. Repeat, but this time, place the same file on the clipboard with the target image/png instead.

Brief code to reproduce:

<!DOCTYPE html>
<input id="i">

<script>
document.getElementById('i').addEventListener('paste', e => {
    console.log(e.clipboardData.files.length);
});

Platform: Linux xxx 6.1.18-1-lts #1 SMP PREEMPT_DYNAMIC Sat, 11 Mar 2023 14:39:23 +0000 x86_64 GNU/Linux (Arch linux)

Actual results:

  1. When the file is placed with target image/jpeg, clipboardData.files is empty.
  2. When the file is placed with target image/png, clipboardData.files shows a file. It is displayed correctly on the webpage as such: document.body.appendChild(new Image(URL.createObjectURL(clipboardData.files[0])));

Expected results:

The clipboard target image/jpeg should be respected.

I can reproduce this Ubuntu22.04 LTS.
CTRL-V to paste works fine with "xclip -target image/png *" even though the image is in jpeg but not with "image/jpeg" nor with "image/jpg".

The link here demonstrate this bug on chromium, and the issues is exactly the same for firefox.

Setting the component so that the developer can have a look over this.
If this is not the correct component, please feel free to change it to a more appropriate one.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core
Blocks: gtkclipboard
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.