Commits

Waylan Limberg committed ef75ed8

safe_mode now has three options: "replace", "remove" and "escape". Setting safe_mode to True gets the old behavior - "replace".

Comments (0)

Files changed (1)

 ENABLE_ATTRIBUTES = True  # @id = xyz -> <... id="xyz">
 SMART_EMPHASIS = 1        # this_or_that does not become this<i>or</i>that
 HTML_REMOVED_TEXT = "[HTML_REMOVED]" # text used instead of HTML in safe mode
-                                     # If blank, html will be escaped.
+
 RTL_BIDI_RANGES = ( (u'\u0590', u'\u07FF'),
                     # from Hebrew to Nko (includes Arabic, Syriac and Thaana)
                     (u'\u2D30', u'\u2D7F'),
     def run(self, text):
         for i in range(self.stash.html_counter) :
             html, safe  = self.stash.rawHtmlBlocks[i]
-            if self.safeMode and not safe:
-                if HTML_REMOVED_TEXT:
+            if self.safeMode and not safe :
+                if str(self.safeMode).lower() == 'escape' :
+                    html = self.escape(html)
+                elif str(self.safeMode).lower() == 'remove' :
+                    html = ''
+                else :
                     html = HTML_REMOVED_TEXT
-                else:
-                    html = self.escape(html)
-                
+                                   
             text = text.replace("<p>%s\n</p>" % (HTML_PLACEHOLDER % i),
                               html + "\n")
             text =  text.replace(HTML_PLACEHOLDER % i, html)