Closed Bug 1572104 Opened 5 years ago Closed 4 years ago

Carriage returns are copied from <pre> blocks under Linux

Categories

(Core :: DOM: Core & HTML, defect, P3)

69 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1547595

People

(Reporter: frederick888, Unassigned)

References

Details

Attachments

(2 files)

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

Steps to reproduce:

  1. Launch Firefox under Linux
  2. Go to https://jsfiddle.net/j3xn9m7k/
  3. Copy the contents from the preview panel in the bottom-right corner

Actual results:

Carriage returns are copied.

Expected results:

Only line feeds are copied.

Environment details:

System: Arch Linux
DE: KDE Plasma
Firefox: 69.0b11 (64-bit)

Hi Frederick,

I've reproduced this bug on Linux 4.18 x86-64 with the Beta version 69.0b12 (64-bit). I've chosen a component. If you consider that there's another component that's more proper for this case you may change it.

Best regards, Flor.

Status: UNCONFIRMED → NEW
Component: Untriaged → Layout: Text and Fonts
Ever confirmed: true
Product: Firefox → Core

The priority flag is not set for this bug.
:jfkthame, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jfkthame)
Priority: -- → P3

I would say this concerns all the text rendered in Firefox for Linux. Every line has Windows style CRLF markers, instead of Unix-style LF marker.
I don't know if it supposed to be like that, but for what it's worth it's managed by GTK, so every GTK3 application has this issue where CRLF markers are used for line breaks.

For more context how it affects users: https://github.com/neovim/neovim/issues/10223.

I suspect this is not a layout bug but whatever serializes the DOM like nsDocumentEncoder... Mirko, you're somewhat familiar with this area, do you know if we have platform-specific serialization-to-clipboard code? If so we could add a check for Linux to convert CRLF to just LF (I'm happy to do it myself or mentor someone into doing it)...

Component: Layout: Text and Fonts → DOM: Core & HTML
Flags: needinfo?(mbrodesser)
Priority: P3 → --

I couldn't reproduce the problem on Ubuntu 18.04 with neither currently Nightly nor current Beta.

Emilio: there's DetermineLineBreak in `nsPlainTextSerializer, but I'm not sure that's the code you were looking for.

Florencia: which OS are you using?

Flags: needinfo?(mbrodesser) → needinfo?(fdiciocco)

Mirko,

This only affects Firefox on Wayland.

Flags: needinfo?(fdiciocco)

Florencia, Emilio, see comment 6.

Flags: needinfo?(jfkthame)
Flags: needinfo?(fdiciocco)
Flags: needinfo?(emilio)

I couldn't reproduce on wayland either...

Flags: needinfo?(emilio)

This issue can be consistently reproduced in my case using Xorg, Nvidia proprietary driver and KDE Plasma under Arch Linux. I actually just installed a clean copy of Arch on a different machine (still Xorg, Nvidia, Plasma) and was still experiencing this problem.

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

Florencia: which OS are you using?

Linux 4.18 x86-64

Flags: needinfo?(fdiciocco)

(In reply to frederick888 from comment #10)

This issue can be consistently reproduced in my case using Xorg, Nvidia proprietary driver and KDE Plasma under Arch Linux. I actually just installed a clean copy of Arch on a different machine (still Xorg, Nvidia, Plasma) and was still experiencing this problem.

Is this a Mozilla build? Or a build from arch's repositories?

(In reply to Florencia Di Ciocco from comment #11)
Florencia, how are you verifying that carriage returns are copied?

Flags: needinfo?(fdiciocco)

@Emilio Yes I can.

Attached video returns.mp4

Hi Emilio,

I attach you a video where I confirmed this bug. I verify that carriage returns are copied by pasting it in a word file. As you can see, it copies two carriage returns.

Flags: needinfo?(fdiciocco)

I personally find it easier to just paste it in e.g. Konsole/Yakuake and it'll give me a warning as shown in the attached screenshot.

Priority: -- → P3

This bug now affects Thunderbird (68.7.0) as well.

May I know whether there are any updates on this issue? I've been playing around with some online IDEs recently and this has been quite annoying.

Are there any ways that I can help, e.g. a mozregression?

frederick888: if you could run mozregression to determine the commit which introduced the failure, that'd be helpful. Other bugs are currently prioritized higher, but if there's an easy fix someone (perhaps me) might find time to fix it.

Hmm... mozregression traced back to a quite old version...

 3:23.81 INFO: Running mozilla-central build for 2018-10-10
 3:31.53 INFO: Launching /tmp/tmplo174ean/firefox/firefox
 3:31.53 INFO: Application command: /tmp/tmplo174ean/firefox/firefox -profile /tmp/tmpd_o8bgwj.mozrunner
 3:31.54 INFO: application_buildid: 20181010235834
 3:31.54 INFO: application_changeset: 2f85c2b55cd2f1b241f27b7ad8b9dfe42dfc139c
 3:31.54 INFO: application_name: Firefox
 3:31.54 INFO: application_repository: https://hg.mozilla.org/mozilla-central
 3:31.54 INFO: application_version: 64.0a1
Was this nightly build good, bad, or broken? (type 'good', 'bad', 'skip', 'retry', 'back' or 'exit' and press Enter): good
 3:41.09 INFO: Narrowed nightly regression window from [2018-10-08, 2018-10-11] (3 days) to [2018-10-10, 2018-10-11] (1 days) (~0 steps left)
 3:41.09 INFO: Got as far as we can go bisecting nightlies...
 3:41.09 INFO: Last good revision: 2f85c2b55cd2f1b241f27b7ad8b9dfe42dfc139c (2018-10-10)
 3:41.09 INFO: First bad revision: 0de23e038872cb0986d7259e16ff966fcc050ae0 (2018-10-11)
 3:41.09 INFO: Pushlog:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=2f85c2b55cd2f1b241f27b7ad8b9dfe42dfc139c&tochange=0de23e038872cb0986d7259e16ff966fcc050ae0

 3:41.09 INFO: Switching bisection method to taskcluster
 3:41.09 INFO: Getting mozilla-central builds between 2f85c2b55cd2f1b241f27b7ad8b9dfe42dfc139c and 0de23e038872cb0986d7259e16ff966fcc050ae0
 3:46.71 WARNING: Skipping build 2f85c2b55cd2: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.2f85c2b55cd2f1b241f27b7ad8b9dfe42dfc139c.firefox.linux64-opt'
 3:46.76 WARNING: Skipping build 0de23e038872: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.0de23e038872cb0986d7259e16ff966fcc050ae0.firefox.linux64-opt'
 3:51.31 WARNING: Skipping build 725a692947dd: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.725a692947dd08a8b60dea0d4387ca5e9a3553f4.firefox.linux64-opt'
 3:51.34 WARNING: Skipping build 389e356499df: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.389e356499dfff9e5411d0fbf8fb9db6c6d2d0b6.firefox.linux64-opt'
 3:51.63 WARNING: Skipping build 9ba60bd44825: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.9ba60bd4482561db2a86f7ebcee1f0b66b32746b.firefox.linux64-opt'
 3:55.74 WARNING: Skipping build 0f1d5395f801: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.0f1d5395f8013b4dafcd4c849a8cccdcf3c26587.firefox.linux64-opt'
 3:55.76 WARNING: Skipping build 20773596530b: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.20773596530b6b6a6fb405a7bd7110a990f8db8f.firefox.linux64-opt'
 3:55.76 WARNING: Skipping build 1a9cbc785296: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.1a9cbc785296806682eb165e0307b05b8f45b7e7.firefox.linux64-opt'
 3:59.83 WARNING: Skipping build 2d2dee08739f: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.2d2dee08739f0293e1ac9e815a9acb80621c3bc4.firefox.linux64-opt'
 3:59.86 WARNING: Skipping build 91b4c3687d75: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.91b4c3687d7563244fbba0f58075779eb89259fb.firefox.linux64-opt'
 3:59.87 WARNING: Skipping build 8dfeff72def3: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.8dfeff72def34dea3ee1a59185a73d2840ae77f3.firefox.linux64-opt'
 4:03.94 WARNING: Skipping build f5681e1f56e6: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.f5681e1f56e6d77989c3f63f9a017f5c94bd74af.firefox.linux64-opt'
 4:03.94 WARNING: Skipping build bf31de5be0dc: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.bf31de5be0dcd71f3257485c66db5627ec3ed205.firefox.linux64-opt'
 4:03.95 WARNING: Skipping build b85ace8c5339: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.b85ace8c5339f5f24e7d104b4a8146dc92bb694d.firefox.linux64-opt'
 4:08.02 WARNING: Skipping build 550aa5330baf: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.550aa5330baf471ec1b9c6a05f4a598bec88ebf6.firefox.linux64-opt'
 4:08.03 WARNING: Skipping build 4845f02cf354: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.4845f02cf3545f00f4a6887a92455b3917296dee.firefox.linux64-opt'
 4:08.06 WARNING: Skipping build 6f8701d1be0c: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.6f8701d1be0ccf42a8e22bfce6f40056a4f58a1b.firefox.linux64-opt'
 4:12.13 WARNING: Skipping build 77491723486d: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.77491723486d3fb28d0001d2c603145696560ce7.firefox.linux64-opt'
 4:12.14 WARNING: Skipping build e96bcfe8669a: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.e96bcfe8669abdb7eaa9f034daba53d44d8c3e51.firefox.linux64-opt'
 4:12.18 WARNING: Skipping build a9616aaeff87: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.a9616aaeff87448588d57c295e16eb4caec420fb.firefox.linux64-opt'
 4:16.25 WARNING: Skipping build 6a6c984745ef: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.6a6c984745eff7fdcaeb6ec930e9c0669abaab9a.firefox.linux64-opt'
 4:16.26 WARNING: Skipping build a3a767ad55fb: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.a3a767ad55fbf01762d41f7e8bff91188e736daf.firefox.linux64-opt'
 4:16.26 CRITICAL: First build 2f85c2b55cd2 is missing, but mozregression can't find a build before - so it is excluded, but it could contain the regression!
 4:21.12 WARNING: Skipping build a19bd92250b6: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.a19bd92250b6d4c7ca6639c632bca4950d2b911d.firefox.linux64-opt'
 4:21.14 WARNING: Skipping build 8bd12e6c3f99: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.8bd12e6c3f9979d00afb2fc699bb292a03962f0a.firefox.linux64-opt'
 4:21.15 WARNING: Skipping build 580c03c8ae38: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.580c03c8ae389ea12073561e2b445312257d7cf3.firefox.linux64-opt'
 4:25.22 WARNING: Skipping build 7a0840d60252: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.7a0840d602524d3b4552a867092267bb3fd5e79e.firefox.linux64-opt'
 4:25.23 WARNING: Skipping build 0ab221f0a996: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.0ab221f0a99689d1cfe3a158ade3818a680ec26d.firefox.linux64-opt'
 4:25.24 WARNING: Skipping build 7fd59dc00149: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.7fd59dc00149b33ede6efb0ed848eef227cae540.firefox.linux64-opt'
 4:29.29 WARNING: Skipping build 067a1c08f91d: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.067a1c08f91d13f9ad8b7c73b40b2a9065d24c0e.firefox.linux64-opt'
 4:29.30 WARNING: Skipping build f2d7836b93f9: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.f2d7836b93f9ad88ef27388df27be1e6510bcdb8.firefox.linux64-opt'
 4:29.31 WARNING: Skipping build ede21c2f2f99: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.ede21c2f2f993c7bb00d37b1e52b62c9f0c4c671.firefox.linux64-opt'
 4:33.57 WARNING: Skipping build 40d620c9c6ee: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.40d620c9c6ee52bc3e3b5181c4336a74044af7c1.firefox.linux64-opt'
 4:33.60 WARNING: Skipping build 0dfb3afc7357: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.0dfb3afc73572ea842e1fbf6ee08644e5570d79d.firefox.linux64-opt'
 4:33.60 WARNING: Skipping build 94a62c1aad52: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.94a62c1aad526dc24dc9186a6ccebb0db276ee87.firefox.linux64-opt'
 4:37.67 WARNING: Skipping build b6abd17c078b: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.b6abd17c078bae35faac3aa50682a7f6a107d490.firefox.linux64-opt'
 4:37.70 WARNING: Skipping build a7f531e64021: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.a7f531e64021113368611572eb0b6683c01d4654.firefox.linux64-opt'
 4:37.74 WARNING: Skipping build d49587f5ccd3: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.d49587f5ccd37180d1f0d980c9dd076e7afa1bcb.firefox.linux64-opt'
 4:41.81 WARNING: Skipping build 4b02380c0bbb: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.4b02380c0bbb5151f1a1f4606c29f2a1cbb70225.firefox.linux64-opt'
 4:41.81 WARNING: Skipping build f8560f7a88a8: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.f8560f7a88a899e10cc103a25099b3c9fc088247.firefox.linux64-opt'
 4:41.84 WARNING: Skipping build 3aca49b2df24: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.3aca49b2df240e86d5b164feb18575681c818c63.firefox.linux64-opt'
 4:45.90 WARNING: Skipping build 8bf31628742d: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.8bf31628742de6153ce9c2ff1ebc16d69b8d605d.firefox.linux64-opt'
 4:45.90 WARNING: Skipping build 6e0139775220: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.6e0139775220f26e08be6494978e64617f4220d2.firefox.linux64-opt'
 4:45.90 CRITICAL: Last build 0de23e038872 is missing, but mozregression can't find a build after - so it is excluded, but it could contain the regression!
 4:49.97 WARNING: Skipping build 8d8c2a0e01b4: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.8d8c2a0e01b424c7719f76f553ff2923f1ddce69.firefox.linux64-opt'
 4:49.98 WARNING: Skipping build ddcd7cc2f3cd: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.ddcd7cc2f3cdd88f5f399f4c59d530aceda0d722.firefox.linux64-opt'
 4:49.99 WARNING: Skipping build b89a744deccb: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.b89a744deccb5be6113036d95c5c208e1ae2b59f.firefox.linux64-opt'
 4:54.07 WARNING: Skipping build e4220fa7a191: Unable to find build info using the taskcluster route 'gecko.v2.mozilla-central.shippable.revision.e4220fa7a191903a814e8cf473cf544fe9762625.firefox.linux64-opt'
 4:54.07 INFO: There are no build artifacts for these changesets (they are probably too old).

From the pushlog there, bug 1497580 seems like a plausible candidate. Tom, any chance you could look at this and see if that's related?

Flags: needinfo?(evilpies)

I just realised that there have been quite some detailed discussions at Bug 1547595, which finally pointed to a GTK issue that the GTK guys didn't want to fix/think it was a bug. Not sure whether it's actually the same problem though, as Bug 1547595 is about Wayland.

Aha -- that does look very relevant, yes.

See Also: → 1547595

Mhm. I suspect the actual bug is somewhere else. Probably somewhere around nsHTMLFormatConverter::Convert. I do wonder why the behavior changed though.

Are we pasting the text/html into something that doesn't accept HTML and instead the data get converted to plaintext?

Flags: needinfo?(evilpies)

@Tom Yes, I pasted the text into Konsole (KDE terminal emulator), which supports plain text only.

It seems pasting the text/html into programs works normally. I tested:

  1. Pasting into https://trix-editor.org/ in Chrome (GTK), which showed up as a code block without empty lines
  2. Pasting into https://github.com/Anchakor/MRichTextEditor (Qt), and there weren't any empty lines either

Ah. I think emilio pointed that out before. We call GetTransferData("text/unicode", getter_AddRefs(item)) here, which already gives us a string with \n line endings.

Still not sure what my patch actually changed.

So wait. The bug here is that you get <Carriage Return> <Line Feed> (CRLF) in your clipboard. We however call gtk_selection_data_set_text with a string that only contains Line Feeds. I only get a Line Feed when testing locally with xclip -o | hexdump. So this must be some kind of GTK bug that you encounter. So dupe Bug 1547595 like comment 23 suggests and some kind of weird GTK behavior that is outside our control.

I think this also likely explained why bug 1497580 might have changed something. We were using UTF8_STRING before and now we are using text/plain;charset=utf-8. GTK is handling those differently and explicitly converts to CRLF: https://gitlab.gnome.org/GNOME/gtk/-/blob/02bbe399df2a60c00b55d792b7d8cb347b199935/gtk/gtkselection.c#L555 !

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE

Are you using X11 or Wayland? You are using KDE so from my understanding the rest of your apps are Qt?

Flags: needinfo?(frederick888)

I'm using X11 and yes most of my other apps are Qt.

Flags: needinfo?(frederick888)

Thanks for the quick reply!

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

Attachment

General

Created:
Updated:
Size: