• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Révision0f78e6d8f1502ba9351f79022afbc78e9be56f59 (tree)
l'heure2010-10-28 06:56:50
AuteurRick Copeland <rcopeland@geek...>
CommiterRick Copeland

Message de Log

[#1088] - mark all markdown-converted text as safe for jinja

Change Summary

Modification

--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -17,6 +17,7 @@ import markdown
1717 import feedparser
1818
1919 from . import macro
20+from . import helpers as h
2021
2122 log = logging.getLogger(__name__)
2223
@@ -38,6 +39,7 @@ class ForgeExtension(markdown.Extension):
3839 # Rewrite all relative links that don't start with . to have a '../' prefix
3940 md.postprocessors['rewrite_relative_links'] = RelativeLinkRewriter(
4041 make_absolute=self._is_email)
42+ md.postprocessors['mark_safe'] = MarkAsSafe()
4143
4244 def reset(self):
4345 self.forge_processor.reset()
@@ -196,6 +198,11 @@ class ForgeTreeProcessor(markdown.treeprocessors.Treeprocessor):
196198 node.attrib['class'] = ' '.join(classes)
197199 return root
198200
201+class MarkAsSafe(markdown.postprocessors.Postprocessor):
202+
203+ def run(self, text):
204+ return h.html.literal(text)
205+
199206 class RelativeLinkRewriter(markdown.postprocessors.Postprocessor):
200207
201208 def __init__(self, make_absolute=False):