1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed 1.5.10: Cannot Paste Formatted Text in Message Window

Discussion in 'Resolved Bug Reports' started by Gene Steinberg, Sep 5, 2016.

  1. Gene Steinberg

    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:

  2. Mike

    Mike XenForo Developer Staff Member

    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?
  3. Gene Steinberg

    Gene Steinberg Well-Known Member

    Apple Mail, TextEdit, Apple Pages, WordPress Dashboard, Dada Mail.
  4. Xon

    Xon Well-Known Member

    I've had users reporting this as well. https://forums.spacebattles.com/threads/pasting-issue.424594/
    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.
    eva2000 likes this.
  5. Mike

    Mike XenForo Developer Staff Member

    There is one new regex that must be the cause, though I don't think it should be catastrophic:
    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.
  6. Mike

    Mike XenForo Developer Staff Member

    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.
  7. Gene Steinberg

    Gene Steinberg Well-Known Member

    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.
  8. Mike

    Mike XenForo Developer Staff Member

    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.
  9. Gene Steinberg

    Gene Steinberg Well-Known Member

    Easy to fix?
  10. Xon

    Xon Well-Known Member

    Do you still need me to chase up a sample of the failing content?
  11. Mike

    Mike XenForo Developer Staff Member

    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.

    Attached Files:

  12. Mike

    Mike XenForo Developer Staff Member

    Nope, should be sorted. Please try the patch and confirm that it resolves the issue for you/him.
    eva2000, Sunka and Xon like this.
  13. Xon

    Xon Well-Known Member

    @Mike, I've deployed the hotfix and have queried the users who have experienced the problem to test it.

    eva2000, Mike and Sunka like this.
  14. Gene Steinberg

    Gene Steinberg Well-Known Member

    My initial test, with the material that wouldn't paste before, is positive. I'll be in touch with updates.
  15. Gene Steinberg

    Gene Steinberg Well-Known Member

    All good. Thanks.

Share This Page