[cpif] r201 - trunk/frontend-web

svn at argo.es svn at argo.es
Fri Jun 29 21:05:05 CEST 2007


Author: alvaro
Date: Fri Jun 29 21:05:04 2007
New Revision: 201

Log:
Bugfix


Modified:
   trunk/frontend-web/parsers.py

Modified: trunk/frontend-web/parsers.py
==============================================================================
--- trunk/frontend-web/parsers.py	(original)
+++ trunk/frontend-web/parsers.py	Fri Jun 29 21:05:04 2007
@@ -3,30 +3,31 @@
 # $Id$
 
 import unittest
-from parser_bbcode import BBCodeParser
-from parser_html import *
+import parser_bbcode
+import parser_html
+from parser_html import escape
 
 def convert_to_html(text):
   from globales import allow_bbcode,allow_html
-  retval = False
-  if not allow_html or not allow_bbcode: 
-    text = escape(text)
+
   if allow_html:
-    parser = HTMLParser()
+    parser = parser_html.HTMLParser()
     parser.reset()
     try:
       parser.feed(text)
       text = parser.get_text()
-      if not text: raise SGMLParseError, "HTML no valido"
-    except SGMLParseError, e:
+      if not text: raise parser_html.SGMLParseError, "HTML no valido"
+    except parser_html.SGMLParseError, e:
       return e or "HTML no valido", None
 
   if allow_bbcode:
-    parser = BBCodeParser()
+    parser = parser_bbcode.BBCodeParser()
     parser.feed(text)
-    retval, text = parser.parse()
+    return parser.parse()
+  
+  text = escape(text)
 
-  return retval, text
+  return False, text
 
 class TestHTMLParser(unittest.TestCase):
   correct_html = (
@@ -59,7 +60,7 @@
   )
 
   def testCorrectHTML(self):
-    parser = HTMLParser()
+    parser = parser_html.HTMLParser()
     html_list = []
     parsed_html_list = []
     global allow_errors
@@ -307,7 +308,6 @@
       assert retval
 
   def testIncorrectXSS(self):
-    parser = BBCodeParser()
     global allow_errors
     allow_errors = False
     print



More information about the cpif mailing list