Closed Bug 1699787 Opened 4 years ago Closed 4 years ago

Pasting tables copied from an Microsoft Excel (any version)/Libre Office Calc to new Gmail message pastes `<table>` and `<img>` of that table

Categories

(Core :: DOM: Editor, defect)

Firefox 86
Desktop
All
defect

Tracking

()

RESOLVED WORKSFORME
Webcompat Priority ?
Tracking Status
firefox87 --- affected
firefox88 --- affected
firefox89 --- affected

People

(Reporter: asterix7502, Assigned: mbrodesser-Igalia)

References

Details

(Keywords: parity-chrome, parity-safari)

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36

Steps to reproduce:

  • Open gmail and log in
  • create a new message
  • open an excel spreadsheet and copy a table (any number of cells)

Actual results:

In the "new message" window the cells are copied twice.

Expected results:

In the "new message" window the cells are copied only once.

Note: this doesn't happen with Chrome browser

Hi, I was able to reproduce this issues in all versions of Firefox, This issue only seems to occur when the user will copy a table from the Desktop Microsoft Excell app, the online version office 365 doesnt seem to be affected by it.
Mirko can you please take a look at this issue ?

Severity: -- → S3
Status: UNCONFIRMED → NEW
Has Regression Range: --- → no
Has STR: --- → yes
Component: Untriaged → DOM: Editor
Ever confirmed: true
Flags: needinfo?(mbrodesser)
OS: Unspecified → Windows 10
Product: Firefox → Core
Hardware: Unspecified → Desktop

Couldn't reproduce the issue with Libre Office Writer on Ubuntu 20.04. Presumably, it's an Excel-specific issue. Will have a closer look.

Excel exports the following HTML flavor:

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link id=Main-File rel=Main-File
href="file:///C:/Users/MIRKOB~1/AppData/Local/Temp/msohtmlclip1/01/clip.htm">
<link rel=File-List
href="file:///C:/Users/MIRKOB~1/AppData/Local/Temp/msohtmlclip1/01/clip_filelist.xml">
<style>
<!--table
	{mso-displayed-decimal-separator:"\,";
	mso-displayed-thousand-separator:"\.";}
@page
	{margin:.75in .7in .75in .7in;
	mso-header-margin:.3in;
	mso-footer-margin:.3in;}
tr
	{mso-height-source:auto;}
col
	{mso-width-source:auto;}
br
	{mso-data-placement:same-cell;}
td
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border:none;
	mso-background-source:auto;
	mso-pattern:auto;
	mso-protection:locked visible;
	white-space:nowrap;
	mso-rotate:0;}
-->
</style>
</head>

<body link="#0563C1" vlink="#954F72">

<table border=0 cellpadding=0 cellspacing=0 width=136 style='border-collapse:
 collapse;width:102pt'>
<!--StartFragment-->
 <col width=68 span=2 style='width:51pt'>
 <tr height=19 style='height:14.25pt'>
  <td height=19 width=68 style='height:14.25pt;width:51pt'>x1</td>
  <td width=68 style='width:51pt'>x2</td>
 </tr>
 <tr height=19 style='height:14.25pt'>
  <td height=19 style='height:14.25pt'>x3</td>
  <td>x4</td>
 </tr>
<!--EndFragment-->
</table>

</body>

</html>

which seems OK.

Works with Chrome.

Pasting the table to data:text/html,<div contenteditable> works with Firefox too, so it seems to be a Gmail-specific bug.

Flags: needinfo?(mbrodesser)
Keywords: parity-chrome

(In reply to Rares Doghi from comment #1)

Hi, I was able to reproduce this issues in all versions of Firefox, This issue only seems to occur when the user will copy a table from the Desktop Microsoft Excell app, the online version office 365 doesnt seem to be affected by it.
Mirko can you please take a look at this issue ?

Could reproduce the issue with Firefox release 85.0.2 too. So it is no recent regression.

Rares: could you please help checking whether this is an older regression?

Presumably the issue is in Gmail-code.

Gmail inserts an <img> of the table after the actual <table>:

<img data-surl="cid:ii_kmltwm3c0" src="blob:https://mail.google.com/d90da3a7-e331-4bbb-98b3-abec376bf716" alt="image.png" width="273" height="77">
Webcompat Priority: --- → ?

Excel exports a bitmap of the table too.

Karl: is this issue something you can look into? I'd like to determine whether the root-cause is in Gecko or Gmail, but practically never debug on Windows.

Flags: needinfo?(kdubost)

The issue occurs with Excel on macOS too. Works with Safari. Hence, it's becoming more likely to be a Gecko-specific issue.

Summary: There is a problem pasting tables copied from an Excel spreadsheet (any version) to new gmail message → Pasting tables copied from an Excel spreadsheet (any version) to new Gmail message pastes `<table>` and `<img>` of that table

Hmm, this is similar to bug 1699935...

See Also: → 1699935

so it's not happening when copying from Google spreadsheets:
The content is a tab/return style

A	B
C	D

But when copying from Numbers on macOS it inserts an image of the table AND a html table of the content.

Flags: needinfo?(kdubost)

And yes as Masayuki is saying, this looks like a duplicate of Bug 1699935

When I copy from google spreadsheet, the clipboard content is text only
when I copy from Numbers the clipboard is Rich Text.

The image is added by by… this very clear and readable code 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

    _.u.$na = function () {
      var c = this.b7a();
      c || (c = UOd(_.mHd(this.r6a())));
      _.hw(!c.equals(((0, _.KXb) (), _.JXb)) && !_.Qv(c.ha));
      var d = c;
      c = _.tG(this.ha, 2);
      var e = 'cid:' + _.Rt(this.QX()),
      f = _.mP(_.Cj);
      if (!_.ORa(_.Vqa, 'data-[a-zA-Z-]+')) throw _.fu('Yq`data-surl').Qa;
      e = _.Eec(f, _.Vqa, e);
      if (!_.WCd.contains(e.ha)) throw _.fu('Xq`' + _.Rt(_.WCd)).Qa;
      d = _.Eec(e, _.fn, d.ha);
      c = _.Eec(d, _.Vf, c);
      return _.nP(c)
    };

Also that's probably more something on the side of gecko than the side of gmail, because if I fake the UA string to be Chrome instead of Firefox.
The issue still occurs. So if there was a specific code path for Chrome and one for Firefox we would have different behavior. Maybe.

Now I can reproduce the issue with Libre Office Calc on Ubuntu 20.04.

There seem to be no differences with Firefox and Chrome when pasting to data:text/html,<div contenteditable> for the paste event, except the order of the flavors:

Chrome:

event.clipboardData.types.length: 4
x.html:10 event.clipboardData.types[0]: text/plain
x.html:10 event.clipboardData.types[1]: text/html
x.html:10 event.clipboardData.types[2]: text/rtf
x.html:10 event.clipboardData.types[3]: Files

Firefox:

10:53:52.326 event.clipboardData.types.length: 4 x.html:7:17
10:53:52.327 event.clipboardData.types[0]: text/html x.html:10:19
10:53:52.327 event.clipboardData.types[1]: text/rtf x.html:10:19
10:53:52.327 event.clipboardData.types[2]: text/plain x.html:10:19
10:53:52.328 event.clipboardData.types[3]: Files

Mirko, did you try to reorder the types in Firefox to see if it was changing the final result?

Trying mirko script on macos: Numbers to contenteditable.

Firefox Nightly 89.0a1 (2021-03-22) (64-bit)

event.clipboardData.types.length: 4
event.clipboardData.types[0]: text/html 
event.clipboardData.types[1]: text/rtf 
event.clipboardData.types[2]: text/plain 
event.clipboardData.types[3]: Files 
event.clipboardData.items.length: 4 
event.clipboardData.files.length: 1 
event.clipboardData.files[0].type: image/png 

Safari Tech Preview Release 122 (Safari 14.2, WebKit 16612.1.6.2)

[Log] event.clipboardData.types.length: 3 
[Log] event.clipboardData.types[0]: Files 
[Log] event.clipboardData.types[1]: text/html 
[Log] event.clipboardData.types[2]: text/plain 
[Log] event.clipboardData.items.length: 3 
[Log] event.clipboardData.files.length: 1 
[Log] event.clipboardData.files[0].type: image/png 

Microsoft Edge Version 91.0.835.0 (Version officielle) Canary (64 bits)

event.clipboardData.types.length: 4
event.clipboardData.types[0]: text/plain
event.clipboardData.types[1]: text/html
event.clipboardData.types[2]: text/rtf
event.clipboardData.types[3]: Files
event.clipboardData.items.length: 4
event.clipboardData.files.length: 1
event.clipboardData.files[0].type: image/png

3 different orders. :)

And this is when I copy from Google Docs Sheets which doesn't exhibit the double content issue

Firefox Nightly 89.0a1 (2021-03-22) (64-bit)

event.clipboardData.types.length: 3 
event.clipboardData.types[0]: application/x-vnd.google-docs-embedded-grid_range_clip+wrapped 
event.clipboardData.types[1]: text/html 
event.clipboardData.types[2]: text/plain 
event.clipboardData.items.length: 3 
event.clipboardData.files.length: 0

One of the obvious difference is that the RTF has been replaced by specific content type for Google AND There is no image.

(In reply to Karl Dubost💡 :karlcow from comment #16)

Mirko, did you try to reorder the types in Firefox to see if it was changing the final result?

I haven't. I'd need to find the relevant code. However, given the scenario of bug 1699935 creates exactly one flavor ("Files"), the order is not the problem -- at least for that bug. Given that bug 1699935 is so similar to this one, I presume changing the order won't fix this one.

Presumably, this is a duplicate of bug 1699935. Waiting for a response from Google developers.

Assignee: nobody → mbrodesser
OS: Windows 10 → All

This is a bug in Gmail. It was reported together with bug 1699935 to Google developers and they claim to have a fix pending.
See 1699935#c13.

Let's keep this ticket open and not close it as a duplicate of bug 1699935, because the STR differ slightly.

I couldn't reproduce the issue, but will keep this ticket open until bug 1699935, which might have the same root-cause, is fixed.

Summary: Pasting tables copied from an Excel spreadsheet (any version) to new Gmail message pastes `<table>` and `<img>` of that table → Pasting tables copied from an Microsoft Excel (any version)/Libre Office Calc to new Gmail message pastes `<table>` and `<img>` of that table

Could not reproduce this issue using latest Nightly 89.0a1 (04.12.2021), Beta 88.0b9 and Release 87.0 on Windows 10 x64. The table is correctly copied from Microsoft Excel into Gmail.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: