------------------------------------------------------------------------------
To reply, visit https://hellosplat.com/s/beanbag/tickets/4685/
------------------------------------------------------------------------------

New ticket #4685 by kyz
For Beanbag, Inc. > Review Board

Status: New
Tags: Priority:Medium, Type:Defect


------------------------------------------------------------------------------
RB.LinkifyUtils.linkifyChildren doesn't linkify flat lists of URLs in Firefox
==============================================================================

# What version are you running?
ReviewBoard 3.0.4

# What's the URL of the page containing the problem?
Any page with a text editor

# What steps will reproduce the problem?
1. Edit a text editor field (e.g. review request -> description)
2. Add text like below (URLs separated by linebreak... and for further 
edification, have more than one paragraph) and save the field

https://google.com
https://yahoo.com

https://bing.com
https://duckduckgo.com


# What is the expected output? What do you see instead?

Expected output is all links are linkified.
Actual output is that only the first link in each paragraph is linkified.

# What operating system are you using? What browser?

* Linux. Firefox 59.0.2
* Windows. Firefox ESR 52.7.3
* Windows. Google Chrome 65.0.3325.181

# Please provide any additional information below.

The problem is that linkChildren is not handling siblings correctly if one is 
replaced. DOM structure before:

    nodeType=1 nodeName=PRE
    - nodeType=1 nodeName=P
      - nodeType=3 (text node https://google.com)
      - nodeType=1 nodeName=BR
      - nodeType=3 (text node https://yahoo.com)
      - nodeType=1 nodeName=BR
    - nodeType=1 nodeName=P
      - nodeType=3 (text node https://bing.com)
      - nodeType=1 nodeName=BR
      - nodeType=3 (text node https://duckduckgo.com)
      - nodeType=1 nodeName=BR

Instead of iterating through all four sibling nodes under the first P, 
linkChildren only iterates through the first one. Because the linkifyText gives 
a changed result back, it replaces the HTML content... this makes the loop 
variable, `node`, a stale reference, and only the newly replaced node has 
.nextSibling set to continue the iteration.

The following diff appears to fix the problem, by no longer referencing (stale) 
node.nextSibling but directly iterating through childNodes.

--- ./reviewboard/static/rb/js/utils/linkifyUtils.es6.js.orig   2018-04-04 
12:27:37.974976735 +0100
+++ ./reviewboard/static/rb/js/utils/linkifyUtils.es6.js        2018-04-04 
12:37:23.974976735 +0100
@@ -184,7 +184,7 @@
      *         by the captured bug ID.
      */
     linkifyChildren(el, bugTrackerURL) {
-        for (let node = el.childNodes[0]; node; node = node.nextSibling) {
+        for (var node of el.childNodes) {
             if (node.nodeType === node.TEXT_NODE) {
                 if (node.textContent) {
                     const newText = RB.LinkifyUtils.linkifyText(


------------------------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to reviewboard-issues+unsubscr...@googlegroups.com.
To post to this group, send email to reviewboard-issues@googlegroups.com.
Visit this group at https://groups.google.com/group/reviewboard-issues.
For more options, visit https://groups.google.com/d/optout.

Reply via email to