Skip to content

Commit

Permalink
Merge pull request #42 from cfpb/sharing-banner-multiline-body
Browse files Browse the repository at this point in the history
Add DOTALL flag to sharing banner body-RE
  • Loading branch information
willbarton committed Jan 5, 2021
2 parents 515b457 + b5ad101 commit fe0a694
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions wagtailsharing/tests/test_wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,11 @@ def test_banner_leaves_links_alone(self):
content = '<body>Link <a href="#">and</a> spaces</body>'
response = self.add_banner_to_response(content)
self.assertContains(response, '<a href="#">and</a>')

def test_body_has_newlines_still_adds_banner(self):
content = """<html><body
>
abcde</body></html>"""
response = self.add_banner_to_response(content)
self.assertContains(response, "wagtailsharing-banner")
2 changes: 1 addition & 1 deletion wagtailsharing/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def add_sharing_banner(page, response):
response.render()

html = force_text(response.content)
body = re.search(r"(?i)<body.*?>", html)
body = re.search(r"(?is)<body.*?>", html)

if body:
endpos = body.end()
Expand Down

0 comments on commit fe0a694

Please sign in to comment.