Skip to content

Commit

Permalink
[bug 703290] Escape HTML comments better, so pages don't truncate aft…
Browse files Browse the repository at this point in the history
…er squirrelly ones.
  • Loading branch information
erikrose committed Nov 30, 2011
1 parent d14e8f3 commit d6ed2ea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 6 additions & 2 deletions apps/sumo/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,13 @@ def parse(self, text, show_toc=None, tags=None, attributes=None,
self.locale = locale

parser_kwargs = {'tags': tags} if tags else {}
return super(WikiParser, self).parse(text, show_toc=show_toc,
return super(WikiParser, self).parse(
text,
show_toc=show_toc,
attributes=attributes or ALLOWED_ATTRIBUTES,
styles=styles or ALLOWED_STYLES, nofollow=nofollow,
styles=styles or ALLOWED_STYLES,
nofollow=nofollow,
strip_comments=True,
**parser_kwargs)

def _hook_internal_link(self, parser, space, name):
Expand Down
13 changes: 13 additions & 0 deletions apps/wiki/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ def test_general_warning_note_inline_custom(self):
eq_('internal', doc('strong span.filepath').text())
eq_('hi!', doc('em span.menu').text())

def test_comments(self):
"""Markup containing taggy comments shouldn't truncate afterward."""
p = WikiParser()

# This used to truncate after the comment when rendered:
eq_(p.parse('Start <!-- <foo --> End'),
'<p>Start <!-- <foo --> End\n</p>')

# Just make sure these don't go awry either:
eq_(p.parse('Start <!-- <foo> --> End'),
'<p>Start <!-- <foo> --> End\n</p>')
eq_(p.parse('Start <!-- foo> --> End'),
'<p>Start <!-- foo> --> End\n</p>')

class TestWikiTemplate(TestCase):
fixtures = ['users.json']
Expand Down
2 changes: 1 addition & 1 deletion vendor/src/py-wikimarkup

0 comments on commit d6ed2ea

Please sign in to comment.