Fixed Furling fails when a URL is copied from Chrome address bar

ibnesayeed

Well-known member
Affected version
XF2.2
It looks like when the URL of a loaded page is copied from Google Chrome's address bar, it is copied as a formatted HTML URL. Pasting it in the RTE results in auto-linking, which fails to furl.

Below is a potentially unfurled link where @Chris D asked me to report it as a bug (pasting the copied URL to reproduce the effect).

https://xenforo.com/community/threa...in-xf-2-2-we-need-this-more-than-ever.182256/

And below is a link which should potentially furl properly (pasting as plain text to reproduce).


I know that chrome is exhibiting this formatted URL copying behavior for a very long time, but the use-case is so common that there should be some fix in place, if possible.
 
Which version of Chrome and which device and OS is this?

This behaviour has been in Chrome and other browsers on various devices for some time and it was fixed at one point and I couldn't reproduce it myself on any of my devices so something may have changed somewhere or part of our previous workaround is no longer working in the new editor.
 
Browser: Google Chrome Version 83.0.4103.116 (Official Build) (64-bit)
OS: elementary OS 5.1.5 Hera (Built on Ubuntu 18.04.4 LTS)
Kernel: Linux 5.3.0-59-generic
Desktop: Pantheon (Based on GTK 3.22.30)
 
I'm not entirely sure, but I wouldn't be surprised if you would have experienced this even on XF 2.1 but I'll need to try and set up a way of testing this and let you know.
 
I'm not entirely sure, but I wouldn't be surprised if you would have experienced this even on XF 2.1 but I'll need to try and set up a way of testing this and let you know.
You are right, the behavior is same for me in XF 2.1 as well. I have just tested it in a demo instance.
 
Nope it’s just a “feature” but I think we’ve only ever had reproducible cases on Windows and Mac. In both of those the behaviour was slightly different. Looks like Chrome on Linux is another slightly different case.
 
Indeed that might be easier and as I know you're comfortable with dev concepts we'll give it a try!

Ideally this needs to be done while you're on the thread view page with the quick reply editor.

First console command:
JavaScript:
var ed = XF.Element.getHandler($('.js-editor'), 'editor');
You'll probably see undefined echoed out.

Second console command:
JavaScript:
ed.ed.events.on('paste.beforeCleanup', function(content) { console.log(content); });
You'll probably see undefined echoed out again.

Now paste a URL into the editor to reproduce the issue. The console should now contain what we saw before our clean up process which should indicate the HTML we need to strip off 🙂

That's the theory anyway ;)
 
JavaScript:
var ed = XF.Element.getHandler($('.js-editor'), 'editor');
// undefined
ed.ed.events.on('paste.beforeCleanup', function(content) { console.log(content); });
// undefined


https://xenforo.com/community/threa...url-is-copied-from-chrome-address-bar.182258/

After registering the callback, when I pasted the above URL from the main clipboard (using Ctrl+V), it yielded the following console log:

Code:
<meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://xenforo.com/community/threads/furling-fails-when-a-url-is-copied-from-chrome-address-bar.182258/">https://xenforo.com/community/threads/furling-fails-when-a-url-is-copied-from-chrome-address-bar.182258/</a>



Then I attempted to paste from the selection/highlight clipboard (using 3 finger tap on the touch pad, which is equivalent to middle button mouse click), it pasted the version of the URL without auto-linking (which is furled properly above), and yielded the following console log:

Code:
https://xenforo.com/community/threads/furling-fails-when-a-url-is-copied-from-chrome-address-bar.182258/
 
checked in chrome windows and chrome android and the temporary behavior that they introduced a while ago is not happening right now. content pasted from omnibox is being pasted as raw text.

i am noticing however that if i copy/cut rich text inside the editor like this:
https://xenforo.com/community/threa...in-xf-2-2-we-need-this-more-than-ever.182256/
and paste using control+shift+v in chrome, it is not being pasted as raw text but the link itself.
 
checked in chrome windows and chrome android and the temporary behavior that they introduced a while ago is not happening right now. content pasted from omnibox is being pasted as raw text.

i am noticing however that if i copy/cut rich text inside the editor like this:
https://xenforo.com/community/threa...in-xf-2-2-we-need-this-more-than-ever.182256/
and paste using control+shift+v in chrome, it is not being pasted as raw text but the link itself.
Yeah that's not something we can reproduce anywhere including macOS and Windows and now Linux apparently!
After registering the callback, when I pasted the above URL from the main clipboard (using Ctrl+V), it yielded the following console log:

Code:
<meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://xenforo.com/community/threads/furling-fails-when-a-url-is-copied-from-chrome-address-bar.182258/">https://xenforo.com/community/threads/furling-fails-when-a-url-is-copied-from-chrome-address-bar.182258/</a>
Perfect! Thanks.

That's not dissimilar to what we already do so I'll need to figure out what the difference is but we should be able to work with that to fix this.
 
that would work for links copied from the omnibox. try copying the link text (select, copy not from context menu) from my above post. control+shift+v is not stripping its formatting for me here in the editor. though i guess i should post it separately as this is not associated with your bug.

i do have a pi where i have chromium. i can probably check if this issue is specific to chrome linux.
 
try copying the link text (select, copy not from context menu) from my above post. control+shift+v is not stripping its formatting for me here in the editor.

Copied from your post and used Ctrl+V below:

i am noticing however that if i copy/cut rich text inside the editor like this:
https://xenforo.com/community/threa...in-xf-2-2-we-need-this-more-than-ever.182256/
and paste using control+shift+v in chrome, it is not being pasted as raw text but the link itself.

Tried again with Ctrl+Shift+V below:

i am noticing however that if i copy/cut rich text inside the editor like this:
and paste using control+shift+v in chrome, it is not being pasted as raw text but the link itself.
 
ok. so just checked on chromium on raspbian. it is not exactly chrome on elementary os so it is not the exact text case. text copied from omnibox pasted as text in the xenforo editor. just like the behavior in chrome windows and chrome android. 😖
 
There is a different in the two pasted blocks above. The former copied HTML markup for the link while the latter was in plain text, but after the rendition, there was an automatic [URL unfurl="true"] BB Code added.
 
That's intentional though as if you've already explicitly pasted or created a link it makes sense to keep it as a link if you're copy/pasting.
Yes, I do not see any problems here, especially since it is surrounded by other text, so furling it might be odd in certain situations.
 
Yeah that's not something we can reproduce anywhere including macOS and Windows and now Linux apparently!

Perfect! Thanks.

That's not dissimilar to what we already do so I'll need to figure out what the difference is but we should be able to work with that to fix this.
This should be fixed now and rolled out here if you want to give it a try?
 
Back
Top Bottom