You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/04/29 23:59:56 UTC

[1/2] git commit: [#5607] make max markdown render length more easily configurable; and lower the default cutoff

Updated Branches:
  refs/heads/master ed4a5a0e8 -> 5fb297e6d


[#5607] make max markdown render length more easily configurable; and lower the default cutoff


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5fb297e6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5fb297e6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5fb297e6

Branch: refs/heads/master
Commit: 5fb297e6dc05ea9a38b43532febbb79d7b4edf0a
Parents: 4510805
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Apr 29 21:59:29 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Apr 29 21:59:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py    |    4 +---
 Allura/allura/tests/test_globals.py |    3 +--
 2 files changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5fb297e6/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index a8d2006..0621b8d 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -60,12 +60,10 @@ from allura.lib.zarkov_helpers import ZarkovClient, zmq
 
 log = logging.getLogger(__name__)
 
-BIG_TEXT_THRESHOLD = 90000
-
 
 class ForgeMarkdown(markdown.Markdown):
     def convert(self, source):
-        if len(source) > BIG_TEXT_THRESHOLD:
+        if len(source) > asint(config.get('markdown_render_max_length', 40000)):
             # if text is too big, markdown can take a long time to process it, so we return it as a plain text
             log.info('Text is too big. Skipping markdown processing')
             escaped = cgi.escape(h.really_unicode(source))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5fb297e6/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index ccf90cc..2adc64c 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -285,8 +285,7 @@ def test_markdown_within_html():
 
 def test_markdown_big_text():
     '''If text is too big g.markdown.convert should return plain text'''
-    from allura.lib.app_globals import BIG_TEXT_THRESHOLD
-    text = 'a' * (BIG_TEXT_THRESHOLD + 1)
+    text = 'a' * 40001
     assert_equal(g.markdown.convert(text), '<pre>%s</pre>' % text)
     assert_equal(g.markdown_wiki.convert(text), '<pre>%s</pre>' % text)
 


[2/2] git commit: [#5607] ticket:319 Render text as plain text if it's too big

Posted by br...@apache.org.
[#5607] ticket:319 Render text as plain text if it's too big


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4510805a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4510805a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4510805a

Branch: refs/heads/master
Commit: 4510805ac0c6fe8594cb220850dd0efe2cc50e4c
Parents: ed4a5a0
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Apr 25 10:49:20 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Apr 29 21:59:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py    |    7 +++++++
 Allura/allura/tests/test_globals.py |    8 ++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4510805a/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index e5b00c7..a8d2006 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -60,9 +60,16 @@ from allura.lib.zarkov_helpers import ZarkovClient, zmq
 
 log = logging.getLogger(__name__)
 
+BIG_TEXT_THRESHOLD = 90000
+
 
 class ForgeMarkdown(markdown.Markdown):
     def convert(self, source):
+        if len(source) > BIG_TEXT_THRESHOLD:
+            # if text is too big, markdown can take a long time to process it, so we return it as a plain text
+            log.info('Text is too big. Skipping markdown processing')
+            escaped = cgi.escape(h.really_unicode(source))
+            return h.html.literal(u'<pre>%s</pre>' % escaped)
         try:
             return markdown.Markdown.convert(self, source)
         except Exception:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4510805a/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index ea7fc1d..ccf90cc 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -283,6 +283,14 @@ def test_markdown_within_html():
 </div>''' in r, r
 
 
+def test_markdown_big_text():
+    '''If text is too big g.markdown.convert should return plain text'''
+    from allura.lib.app_globals import BIG_TEXT_THRESHOLD
+    text = 'a' * (BIG_TEXT_THRESHOLD + 1)
+    assert_equal(g.markdown.convert(text), '<pre>%s</pre>' % text)
+    assert_equal(g.markdown_wiki.convert(text), '<pre>%s</pre>' % text)
+
+
 @td.with_wiki
 def test_markdown_basics():
     with h.push_context('test', 'wiki', neighborhood='Projects'):