Skip to content

Commit

Permalink
Merge branch 'pr/136'
Browse files Browse the repository at this point in the history
  • Loading branch information
jsocol committed Feb 7, 2015
2 parents 9d16a87 + e74bf51 commit 079a376
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bleach/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ def replace_nodes(tree, new_frag, node, index=0):
# capture any non-tag text at the start of the fragment
if new_tree.text:
if index == 0:
tree.text = tree.text or ''
tree.text += new_tree.text
else:
tree[index-1].tail = tree[index-1].tail or ''
tree[index-1].tail += new_tree.text
# the put in the tagged elements into the old tree
for n in new_tree:
Expand Down
7 changes: 7 additions & 0 deletions bleach/tests/test_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,10 @@ def test_elements_inside_links():

eq_('<a href="#" rel="nofollow"><strong>bold</strong> hello<br></a>',
linkify('<a href="#"><strong>bold</strong> hello<br></a>'))


def test_remove_first_childlink():
expect = '<p>something</p>'
callbacks = [lambda *a: None]
eq_(expect,
linkify('<p><a href="/foo">something</a></p>', callbacks=callbacks))

0 comments on commit 079a376

Please sign in to comment.