Fixed Uncaught TypeError console error when triple click quoting next to code block

Optic

Well-known member
Affected version
2.0.1
If you triple click a line/paragraph (with a code block directly underneath) to highlight it, then click "Reply" to quote it in the Quick Reply box below, it generates a browser console error (and the quote therefore doesn't appear in the text box):
JavaScript:
Uncaught TypeError: Cannot read property 'match' of undefined
    at HTMLDivElement.<anonymous> (core-compiled.js?_v=b7a999dd:35)
    at Function.each (jquery.min.js:2)
    at r.fn.init.each (jquery.min.js:2)
    at Object.unparseBbCode (core-compiled.js?_v=b7a999dd:34)
    at click (message.min.js?_v=b7a999dd:16)
    at c._click (core-compiled.js?_v=b7a999dd:111)
    at b (core-compiled.js?_v=b7a999dd:109)
    at HTMLAnchorElement.<anonymous> (core-compiled.js?_v=b7a999dd:112)
    at HTMLDocument.dispatch (jquery.min.js:3)
    at HTMLDocument.q.handle (jquery.min.js:3)

I made a test topic here:
https://xenforo.com/community/threads/test.141072/

I could only reproduce this on Google Chrome, works fine on Firefox..
 
Well, that was easier than I thought it might be. This is just caused by a dodgy assumption that if we detect a code block in the selection that it is actually complete. In this specific case if you triple click, although you can't see it, you end up selecting the parent element of the code block and part of the code block title block. This is enough for us to make us think that there is a code block, but not enough to make the proceeding regex to work, hence the error.

Sorted now for the next release, thank you.
 
Back
Top Bottom