Closed Bug 1699935 Opened 4 years ago Closed 4 years ago

Clipboard image copy-pastes twice in Gmail

Categories

(Core :: DOM: Editor, defect, P2)

Firefox 86
x86_64
All
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bugzilla, Assigned: mbrodesser-Igalia)

References

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0

Steps to reproduce:

To reproduce, take a screenshot of your screen, and try copy-pasting it from your clipboard directly as embedded picture in Gmail. Note that it's important to paste from clipboard, not "pulling the image from a folder".

For screenshots, I use an opensource tool GreenShot. But I tried copying a section of a picture in Paint - and the same bug is present.

This doesn't happen in Chrome or other browsers I tried.
I'm using Firefox v86.0.1 (64-bit), on Windows10 Pro.

Actual results:

Clipboard image is pasted twice in Gmail, consecutively.

Expected results:

We should have a single pasted image in the body of the email.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Editor' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → DOM: Editor
Product: Firefox → Core

Hmm, it's odd. I cannot reproduce it if I copy image in Firefox and paste it into the Gmail's composer.

Karl-san, could you take a look? I guess that this is a bug of Gmail because I cannot reproduce this with contenteditable without any script.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(kdubost)
OS: Unspecified → Windows 10
Hardware: Unspecified → x86_64

on macOS

  1. Have an image on the Desktop
  2. Select the image by tapping it once or clicking it once (image is highlighted)
  3. Command C to copy the image.
  4. Open the notes.app
  5. in a new note, command V to paste the image (image appears in the note)
  6. Open Firefox Nightly 89.0a1 (2021-03-22) Clean Profile
  7. go to mail.google.com (eventually log in)
  8. Compose new message (a small window appears at the bottom right of your screen)
  9. Put the cursor in the body area of the composition window
  10. Command V to paste the image (an image appears in the body)

So no issue for me too. This is working as intended.

Let see if oana can reproduce on the same browser version with windows.

Flags: needinfo?(kdubost) → needinfo?(oana.arbuzov)
Attached video 2021-03-22 bugzilla.mp4

Here is a video demo of the issue.
Tested again on "Private browser", with no cookies or cache, and all Firefox plugins disabled.
The issue is still present.

Thank you for helping! :)

Ah understood. I can reproduce.

This is happening only if the screenshot to clipboard is done.
Not going through a copy - paste sequence

I wonder what are the differences in between the two.

So on macos to reproduce, you may for example when taking the screenshot do command + shift + 5, then select capture with the option to the clipboard.

paste event is the same in both cases with identical clipboardData as far as I can tell. There is an interesting difference of behavior.

Copy-Paste -> Add the name of the file, and the content of the image
Screenshot-Clipboard-Paste -> Add twice the image but no name of the file.

in https://mail.google.com/_/scs/mail-static/_/js/k=gmail.main.en.dZgW9hT0qTE.O/am=rvN_CQ8AvtuBvw1DMgUAAA0ECAASanT3Vkrlf-QAgAWobwwPB-SKI0DmELkBAAAAAAAAAAAAAAAAAACAXVBpgg/d=1/exm=a,b/ed=1/im=1/dg=0/br=1/ct=zgms/rs=AHGWq9AKWUMVFrkJqodEXeXBvyHzfr_YMQ/m=m,m_i,i20jfd,lKrWxc,hkjXJ,gYOl6d,HXLjIb,DL8jZe,xaQcye,oRmHt,E1P0kd,pE92lb,v2eEBc

    q0d = function (c, d) {
      return function h(f, g) {
        g = void 0 === g ? !0 : g;
        var l = d;

f here is the event you can log f with the condition f.type === 'paste'

in gmail code there is And it goes through, and it seems to do the same thing in both cases.

    F$h.prototype.aib = function (c) {
      var d = c.Hf().clipboardData;
      if (d) {
        var e = d.items;
        if (e && 1 < e.length) {
          e = _.Oo(e, function (h) {
            return h.kind == _.Ai && _.jIg.includes(h.type)
          });
          var f = d.getData(_.qya);
          d = d.getData(_.Bn);
          var g;
          if (g = e) {
            if (!(f = f && G$h(this, f)) && (f = d)) try {
              f = H$h.has(_.cA(d).wa)
            } catch (h) {
              f = !1
            }
            g = f
          }
          if (g) {
            e = e.getAsFile();
            if (this.ha.Cd(e)) return c.preventDefault(),
            !0;
            this.ha.ha.execCommand(_.hIg, e);
            c.preventDefault();
            return !0
          }
        }
      }
      return !1
    };
OS: Windows 10 → All
Flags: needinfo?(oana.arbuzov)

Reproducible on Ubuntu too:

<div id=":sy" class="Am Al editable LW-avf tS-tW tS-tY" hidefocus="true" aria-label="Message Body" g_editable="true" role="textbox" aria-multiline="true" style="direction: ltr; min-height: 40px;" tabindex="1" spellcheck="false" contenteditable="true">

<img data-surl="cid:ii_kmn6si290" src="blob:https://mail.google.com/bd9273f4-2ca1-492c-8ed9-2b37fd12b449" alt="image.png" width="150" height="82">

<br>

<img data-surl="cid:ii_kmn6si2u1" src="blob:https://mail.google.com/817a55a6-7b2a-4c51-9dfa-77a06d108b01" alt="image.png" width="150" height="82"><br><br>
</div>

While trying to figure out which code-paths in Gecko are taken, I've noticed
PasteCommand::DoCommand is called, but is a no-op because TextEditor::PasteAsAction returns early.

When pasting to <div contenteditable>, where the issue doesn't occur, TextEditor::PasteAsAction does not return early and proceeds with pasting.

Interestingly, after pasting an image to Gmail in Chrome, I can't undo the pasting. That works in Firefox.

With

var oldEPD = Event.prototype.preventDefault;
Event.prototype.preventDefault = function() {
    debugger;
    oldEPD.call(this);
};

(thanks to this stackoverflow post)

one can observe that preventDefault() is called for some paste events, which might be Gmail's code.

Notified Google developers about this issue. Let's see if they can help determining whether the bug is in Gmail or Gecko.

Assignee: nobody → mbrodesser
Severity: -- → S3
Priority: -- → P2

A Google developer confirmed the bug is in Gmail's code. They have fixed the issue and are going to rollout it as part of their standard release procedure. Once it's clear when that fix will reach all end users, we should verify it and close this ticket.

Can confirm it happening on firefox 87.0 64 bit on windows 10. This has been going on for at least 10 days.

Relieved it's not an issue with my vision or medication

(In reply to Mirko Brodesser (:mbrodesser) -- away until 7th of April 2021 from comment #13)

A Google developer confirmed the bug is in Gmail's code. They have fixed the issue and are going to rollout it as part of their standard release procedure. Once it's clear when that fix will reach all end users, we should verify it and close this ticket.

Occurs in Chrome 89.0.4389.90 as well.

Hello! Unfortunatelly I wasn't able to reproduce the issue with the Firefox 86.0.1 with the STR provided. However since the issue is a Google issue I can confirm that it doesn't occur anymore with firefox 86.0.1, 87.0, 88.0b9 and 89.0a1 on all OS's. I also verified the issue with the latest Google Chorme (89.0.4389.114) 64 bit release and it isn't reproducing anymore.

I will mark this issue as as resolved WORKSFORME, if it's not the right resolution please reopen this issue.

Thank you!

Status: NEW → RESOLVED
Has STR: --- → yes
Closed: 4 years ago
Resolution: --- → WORKSFORME

I still have this issue - Firefox 87 on Windows 10.

I confirm that I still have the issue:
Firefox 87 on Ubuntu 20.04.

Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---

Couldn't reproduce the issue with current Nightly on Ubuntu 20.04. But will keep the ticket open for now.

The issue is resolved for me (original poster), I'm still on Windows10Pro 64bit, but I did upgrade to Firefox v87.0
Can't speak to Ubuntu users, but I hope that info helps someone.
Thank you all again!

:sjperry, :gianni: does the issue still occur for you? If so, can you please try refreshing Gmail and if that doesn't work, clearing the cache?

Flags: needinfo?(sjperry)
Flags: needinfo?(giannife)

Thanks for asking, the issue is fixed on Firefox 87 on Ubuntu 20.04, tomorrow I'll test in on windows 10

Flags: needinfo?(giannife)

(In reply to Mirko Brodesser (:mbrodesser) from comment #22)

:sjperry, :gianni: does the issue still occur for you? If so, can you please try refreshing Gmail and if that doesn't work, clearing the cache?

No it does not. Just tested in Firefox 87 on two Windows 10 machines and pasting image into Gmail works correctly now.

Flags: needinfo?(sjperry)

Tested with Firefox 87 on Ubuntu 20.04, Windows 10, Windows server 2012 and 2016, MacOS Big Sur.
No bug anymore. I consider it as fixed. thx.

Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → WORKSFORME

I have this bug in the last version of Firefox, 89.0.

no problem here (I had it in the past)
firefox 89 on ubuntu 20.04

I can't replicate the issue, it's still fixed for me.
Windows 10 Pro 64bit, Firefox 88.0.1 (64-bit).

I have also this issue, when using the built in Windows 10 snap tool or using the free Greenshot tool.
When I paste the image in our BMS or IT Glue tools, I get the pasted image twice.
If i test the same sequense in Edge: no problems.
No issues with GMail...

FF version: 89.0 (64-bits) Dutch

ndaltamirano, martijn_online: thanks for your feedback. Forwarded this to Gmail developers.

ndaltamirano: which OS were you using?

Flags: needinfo?(ndaltamirano)

(In reply to Mirko Brodesser (:mbrodesser) from comment #30)

ndaltamirano, martijn_online: thanks for your feedback. Forwarded this to Gmail developers.

ndaltamirano: which OS were you using?

I'm using W10.

Flags: needinfo?(ndaltamirano)

(In reply to ndaltamirano from comment #31)

(In reply to Mirko Brodesser (:mbrodesser) from comment #30)

ndaltamirano, martijn_online: thanks for your feedback. Forwarded this to Gmail developers.

ndaltamirano: which OS were you using?

I'm using W10.

Thanks.
Just to be sure: does the issue indeed occur on Gmail?

Flags: needinfo?(ndaltamirano)

(In reply to Mirko Brodesser (:mbrodesser) from comment #32)

(In reply to ndaltamirano from comment #31)

(In reply to Mirko Brodesser (:mbrodesser) from comment #30)

ndaltamirano, martijn_online: thanks for your feedback. Forwarded this to Gmail developers.

ndaltamirano: which OS were you using?

I'm using W10.

Thanks.
Just to be sure: does the issue indeed occur on Gmail?

No. It occurs whenever I copy and paste an image from Firefox to some websites in Chrome.

You can try it by using https://keep.google.com. Copy an image from Firefox, and paste it in a note in there.

I can also reproduce this on WhatsApp web, and Facebook Messenger.

It seems the problem is copying from Firefox, and pasting into Chrome.

This wasn't happening on the previous version, before the new Firefox UI was rolled out.

Flags: needinfo?(ndaltamirano)

Also, this is a recurring use case for me, because I use Firefox as my browser, and also use All-In-One messenger, which is based on Chrome.

Copy pasta problem confirmed on firefox 89.0 and chrome 91 on windows 10.

In firefox, right click to copy an image.

Go to https://imgur.com/upload

press Ctrl+V

The image gets pasted twice.

(In reply to ndaltamirano from comment #33)

(In reply to Mirko Brodesser (:mbrodesser) from comment #32)

(In reply to ndaltamirano from comment #31)

(In reply to Mirko Brodesser (:mbrodesser) from comment #30)

ndaltamirano, martijn_online: thanks for your feedback. Forwarded this to Gmail developers.

ndaltamirano: which OS were you using?

I'm using W10.

Thanks.
Just to be sure: does the issue indeed occur on Gmail?

No. It occurs whenever I copy and paste an image from Firefox to some websites in Chrome.

You can try it by using https://keep.google.com. Copy an image from Firefox, and paste it in a note in there.

I can also reproduce this on WhatsApp web, and Facebook Messenger.

It seems the problem is copying from Firefox, and pasting into Chrome.

This wasn't happening on the previous version, before the new Firefox UI was rolled out.

The issue didn't reproduce with Ubuntu 20.04.

(In reply to gianni from comment #35)

Copy pasta problem confirmed on firefox 89.0 and chrome 91 on windows 10.

Instead of "chrome 91", do you mean "Nightly 91"?

In firefox, right click to copy an image.

Go to https://imgur.com/upload

press Ctrl+V

The image gets pasted twice.

The issue didn't reproduce on Ubuntu 20.04.

For issues with other websites than Gmail, please file separate tickets.

(In reply to Mirko Brodesser (:mbrodesser) from comment #38)

For issues with other websites than Gmail, please file separate tickets.

The issue is not with specific websites, it's with Chrome.

(In reply to ndaltamirano from comment #39)

(In reply to Mirko Brodesser (:mbrodesser) from comment #38)

For issues with other websites than Gmail, please file separate tickets.

The issue is not with specific websites, it's with Chrome.

Sorry, should've been clearer: for clipboard image pasting bugs happening not only on Gmail, please file separate tickets. This ticket was about a Gmail-specific bug.

(In reply to Mirko Brodesser (:mbrodesser) from comment #40)

(In reply to ndaltamirano from comment #39)

(In reply to Mirko Brodesser (:mbrodesser) from comment #38)

For issues with other websites than Gmail, please file separate tickets.

The issue is not with specific websites, it's with Chrome.

Sorry, should've been clearer: for clipboard image pasting bugs happening not only on Gmail, please file separate tickets. This ticket was about a Gmail-specific bug.

Ok, I just did. Not sure if there's any mistake on the report. If so, could you please repost it as it should be?

https://bugzilla.mozilla.org/show_bug.cgi?id=1716016

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: