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/05/03 23:57:45 UTC

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

[#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/db/6007
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)