changeset 2783:a93c07ade43a beta

Added huge diff protection for RSS/ATOM feeds. It can really be a performance killer for huge diffs.
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 02 Sep 2012 23:29:07 +0200
parents d03d51b6541e
children c85746b607bd f1f01e951008
files rhodecode/controllers/feed.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/feed.py	Sun Sep 02 23:08:39 2012 +0200
+++ b/rhodecode/controllers/feed.py	Sun Sep 02 23:29:07 2012 +0200
@@ -59,8 +59,14 @@
 
     def __changes(self, cs):
         changes = []
-
-        diffprocessor = DiffProcessor(cs.diff())
+        _diff = cs.diff()
+        # we need to protect from parsing huge diffs here other way
+        # we can kill the server, 32*1024 chars is a reasonable limit
+        HUGE_DIFF = 32 * 1024
+        if len(_diff) > HUGE_DIFF:
+            changes = ['\n ' + _('Changeset was too big and was cut off...')]
+            return changes
+        diffprocessor = DiffProcessor(_diff)
         stats = diffprocessor.prepare(inline_diff=False)
         for st in stats:
             st.update({'added': st['stats'][0],