Fixed 1.5.10: Cannot Paste Formatted Text in Message Window

Gene Steinberg

Well-known member
Since installing version 1.5.10, I can no longer paste formatted text into a forum window. I have tried the latest Chrome, Opera and Safari on OS X 10.11.6 (El Capitan), the same browsers with the most recent macOS Sierra Public Beta, and the latest edition of Windows 10 with the Edge browser.

The attempt to paste text shows absolutely nothing. I can paste formatted text into other non-XF forums, WordPress, etc. — exactly as before.

With a late beta of iOS 10 on my iPhone 6, plain text works, formatted text appears and promptly vanishes from the message window.

If the text is unformatted, no problem whatever. Firefox doesn't appear to support putting formatted text into a forum message window.

I have tested this problem in this forum, and on the three XF forums on my sites. Same symptoms. I also notice that putting in a full URL in my forum no longer displays the title attribute as it used to.

You can see the formatted text displayed in a forum window on one of my forums that was posted before your last update:

http://www.theparacast.com/forum/threads/your-paracast-newsletter-august-28-2016.17732/
 
I've had users reporting this as well. https://forums.spacebattles.com/threads/pasting-issue.424594/
I've been copying from googledocs to the text editor and just this week it stopped working. It works better on SV but stopped working for my latest update. I've experimentally determined that it has something to do with the amount of text. I can paste a certain amount but once it reaches that amount the paste command simply fails.

Copy&pasting from Googledocs produces some horrible HTML, my guess is the changes bb_code_edit.js have caused a regex to catestrophically fail and return an empty string on sufficiently long/complex input.
 
There is one new regex that must be the cause, though I don't think it should be catastrophic:
Code:
html = html.replace(/(( ){2,})( )?/gi,
There shouldn't be any real backtracking. I do have a case where it's taking ~2 seconds to process that, but it did also paste in about 550KB of HTML (this wasn't a document; it was a massive planning table) so I'm not sure that's really representative.

The is another regex change, but it also only applies within <pre> tags so I don't think that should come up often.
 
In doing some testing, I don't think the regex I mentioned before is executing particularly slowly. When I do some big pastes, there is a bit of a delay, but that appears to be from code that wasn't changed recently. I haven't had a case where it's completely failed, though I am testing on a desktop; mobile could be worse, but also less likely to be a case where you're pasting a huge amount of content.

@Xon, do you think the user could share a Google doc publicly where they can reproduce the problem? Thus far, I haven't managed to reproduce a complete failure.
 
I was able to copy and paste that test and post it here in Chrome: https://xenforo.com/community/threads/paste-test.120448/ I did have to chop some text out after the fact to get it under 10,000 characters but that didn't apply to the paste.

I was also able to copy and paste in Firefox too. Can you provide the specific source you're copying from?
Mike, it's fine if you copy from one XF forum to another.

That's NOT the problem.

The problem occurs when you copy from other source, such as the ones I listed above. If you want to reproduce the problem, try duplicating the setups I reported. Four operating systems, four browsers. I think I've made a pretty good effort to determine the conditions under which it occurred. It all started with 1.5.10, so SOMETHING changed. And it's beyond one computer and OS and one browser, obviously.
 
The issue is that it appears to be more content specific than anything else and my original tests didn't have content that triggered it, no matter where I was pasting from (which is one of the reasons I was trying to get specific content to test with).

I've tried again and I have content that appears to trigger the issue. It's not the regex failing but the code within it erroring if there's no space after the nbsp.
 
This is fixed now. I've attached patched files. 1.5.10 has been updated (1.5.10a) to indicate that these changes have been included in the release from roughly this message.

You want to overwrite js/xenforo/bb_code_edit.js and js/xenforo/full/bb_code_edit.js with the corresponding versions from the attachment. Note that you may need to hard refresh your browser for it to get the updated JS files.
 

Attachments

Back
Top Bottom