Repository: mozilla/bleach

Issue:
Children of <pre> tags should not be linkified when skip_pre=True (patch attached)
The children of `pre` tags should not be linkified when `skip_pre` is on 

```
diff --git a/bleach/__init__.py b/bleach/__init__.py
index 48b6512..4c2dd1b 100644
--- a/bleach/__init__.py
+++ b/bleach/__init__.py
@@ -300,7 +300,7 @@ def linkify(text, callbacks=DEFAULT_CALLBACKS, skip_pre=False,
                 if node.tag == ETREE_TAG('pre') and skip_pre:
                     linkify_nodes(node, False)
                 elif not (node in _seen):
-                    linkify_nodes(node, True)
+                    linkify_nodes(node, parse_text)
 
             current_child += 1
 
diff --git a/bleach/tests/test_links.py b/bleach/tests/test_links.py
index 62da8d1..ae0fba7 100644
--- a/bleach/tests/test_links.py
+++ b/bleach/tests/test_links.py
@@ -314,6 +314,13 @@ def test_skip_pre():
     eq_(nofollowed, linkify(already_linked))
     eq_(nofollowed, linkify(already_linked, skip_pre=True))
 
+def test_skip_pre_child():
+    # Don't linkify the children of pre tags.
+    intext = '<pre><code>http://foo.com</code></pre>http://bar.com'
+    expect = '<pre><code>http://foo.com</code></pre><a href="http://bar.com" rel="nofollow">http://bar.com</a>'
+    output = linkify(intext, skip_pre=True)
+    eq_(expect, output)
+
 
 def test_libgl():
     """libgl.so.1 should not be linkified."""
```

Discussion:

Patch:
diff --git a/bleach/__init__.py b/bleach/__init__.py
index 3092cb7..ac163d1 100644
--- a/bleach/__init__.py
+++ b/bleach/__init__.py
@@ -315,7 +315,7 @@ def linkify(text, callbacks=DEFAULT_CALLBACKS, skip_pre=False,
                 if node.tag == ETREE_TAG('pre') and skip_pre:
                     linkify_nodes(node, False)
                 elif not (node in _seen):
-                    linkify_nodes(node, True)
+                    linkify_nodes(node, parse_text)
 
             current_child += 1
 


Test patch:
diff --git a/bleach/tests/test_links.py b/bleach/tests/test_links.py
index 62da8d1..2958f5e 100644
--- a/bleach/tests/test_links.py
+++ b/bleach/tests/test_links.py
@@ -314,6 +314,13 @@ def test_skip_pre():
     eq_(nofollowed, linkify(already_linked))
     eq_(nofollowed, linkify(already_linked, skip_pre=True))
 
+    eq_(
+        linkify('<pre><code>http://example.com</code></pre>http://example.com',
+                skip_pre=True),
+        ('<pre><code>http://example.com</code></pre>'
+         '<a href="http://example.com" rel="nofollow">http://example.com</a>')
+    )
+
 
 def test_libgl():
     """libgl.so.1 should not be linkified."""