Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
fix bug 769441 - catch difflib recursion error
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder committed Jul 12, 2012
1 parent 070fc81 commit 8282439
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/wiki/helpers.py
Expand Up @@ -5,6 +5,7 @@
from jingo import register
import jinja2
from tidylib import tidy_document
from tower import ugettext as _

from wiki import DIFF_WRAP_COLUMN
from wiki import parser
Expand Down Expand Up @@ -73,8 +74,13 @@ def diff_table(content_from, content_to):
html_diff = difflib.HtmlDiff(wrapcolumn=DIFF_WRAP_COLUMN)
from_lines = tidy_from.splitlines()
to_lines = tidy_to.splitlines()
diff = html_diff.make_table(from_lines, to_lines, context=True,
numlines=constance.config.DIFF_CONTEXT_LINES)
try:
diff = html_diff.make_table(from_lines, to_lines, context=True,
numlines=constance.config.DIFF_CONTEXT_LINES)
except RuntimeError:
# some diffs hit a max recursion error
message = _(u'There was an error generating the content.')
diff = '<div class="warning"><p>%s</p></div>' % message
return jinja2.Markup(diff)

@register.function
Expand Down

0 comments on commit 8282439

Please sign in to comment.