[cpif] r240 - trunk/frontend-web
svn at argo.es
svn at argo.es
Wed Jul 4 00:51:39 CEST 2007
Author: alvaro
Date: Wed Jul 4 00:51:36 2007
New Revision: 240
Log:
Cambiados valores por algo mas politicamente correcto
Modified:
trunk/frontend-web/parser_bbcode.py
trunk/frontend-web/parser_html.py
trunk/frontend-web/parser_urls.py
trunk/frontend-web/parsers.py
Modified: trunk/frontend-web/parser_bbcode.py
==============================================================================
--- trunk/frontend-web/parser_bbcode.py (original)
+++ trunk/frontend-web/parser_bbcode.py Wed Jul 4 00:51:36 2007
@@ -6,15 +6,15 @@
allow_errors = False
allowed_tags = {
-# "bbcode": (start tag, end tag (if needed), True if allows arguments, context)
+# "bbcode": (start tag, end tag (if needed), True if allows arguments, context where ir is NOT permitted)
"b": ('<strong>', '</strong>', False, 'strong'),
"u": ('<span style="text-decoration:underline">', '</span>', False, 'span'),
"s": ('<strike>', '</strike>', False, 'strike'),
- "size": ('<span style="font-size:%(arg)s">', '</span>', True, 'span'),
+ "size": ('<span style="font-size:%(arg)s">', '</span>', True, None),
"i": ('<em>', '</em>', False, 'em'),
"url": ('<a href="%(arg)s">', '</a>', True, 'a'),
- "quote*": ('<blockquote>', '</blockquote>', False, 'blockquote'),
- "quote": ('<blockquote><h4>%(arg)s escribió:</h4>', '</blockquote>', True, 'blockquote'),
+ "quote*": ('<blockquote>', '</blockquote>', False, None),
+ "quote": ('<blockquote><h4>%(arg)s escribió:</h4>', '</blockquote>', True, None),
"img": ('<img src="%(arg)s" />', None, True, None)
}
@@ -234,7 +234,7 @@
'[b]Ay, se me ha olvidado cerrar',
'[url][/url]',
'[b][/url]hola[/url]',
- '[b]caca[url]hola[/b][/url]',
+ '[b]foo[url]hola[/b][/url]',
"""Un texto [b]mas[/b] largo, con [b]negritas y [n]cursivas[/i]
[/b] e incluso [url="laurl"]enlaces [/b]con negritas[/b] dentro[/url]""")
Modified: trunk/frontend-web/parser_html.py
==============================================================================
--- trunk/frontend-web/parser_html.py (original)
+++ trunk/frontend-web/parser_html.py Wed Jul 4 00:51:36 2007
@@ -166,19 +166,19 @@
import unittest
class TestHTML(unittest.TestCase):
correct_html = (
- ('<b>caca</b>', '<b>caca</b>'),
+ ('<b>foo</b>', '<b>foo</b>'),
('b>', 'b>'),
('<script>', '<script>'),
- ('<a href="http://blablabla.com/index.php?caca=1&mierda=2">bla bla</a>',
- '<a href="http://blablabla.com/index.php?caca=1&mierda=2">bla bla</a>'),
- ('<a href="http://blablabla.com/index.php?caca=1&mierda=2" title="caca">bla bla </a>',
- '<a href="http://blablabla.com/index.php?caca=1&mierda=2" title="caca">bla bla </a>'),
- ('<img src="http://blablabla.com/index.php?caca=1&mierda=2" />',
- '<img src="http://blablabla.com/index.php?caca=1&mierda=2" />'),
- ('<img src="http://blablabla.com/index.php?caca=1&mierda=2" alt="caca">',
- '<img src="http://blablabla.com/index.php?caca=1&mierda=2" alt="caca" />'),
- ('<img src="http://blablabla.com/index.php?caca=1&mierda=2" alt="caca"></img>',
- '<img src="http://blablabla.com/index.php?caca=1&mierda=2" alt="caca" />'),
+ ('<a href="http://blablabla.com/index.php?foo=1&bar=2">bla bla</a>',
+ '<a href="http://blablabla.com/index.php?foo=1&bar=2">bla bla</a>'),
+ ('<a href="http://blablabla.com/index.php?foo=1&bar=2" title="foo">bla bla </a>',
+ '<a href="http://blablabla.com/index.php?foo=1&bar=2" title="foo">bla bla </a>'),
+ ('<img src="http://blablabla.com/index.php?foo=1&bar=2" />',
+ '<img src="http://blablabla.com/index.php?foo=1&bar=2" />'),
+ ('<img src="http://blablabla.com/index.php?foo=1&bar=2" alt="foo">',
+ '<img src="http://blablabla.com/index.php?foo=1&bar=2" alt="foo" />'),
+ ('<img src="http://blablabla.com/index.php?foo=1&bar=2" alt="foo"></img>',
+ '<img src="http://blablabla.com/index.php?foo=1&bar=2" alt="foo" />'),
('&', '&'),
)
@@ -186,13 +186,13 @@
'<b>',
'<b',
'</b>',
- '<a href="http://blablabla.com/index.php?caca=1&mierda=2">bla bla',
- '<a href="http://blablabla.com/index.php?caca=1&mierda=2">bla bla </as>',
- '<a href="http://blablabla.com/index.php?caca=1&mierda=2" taitle="caca">bla bla </a>',
- '<a href="http://blablabla.com/index.php?caca=1&mierda=2" taitle="caca">bla bla </a>',
- '<a href="http://blablabla.com/index.php?caca=1&mierda=2" title="caca" de la vaca>bla bla <a>',
- '<img sorcerer="http://blablabla.com/index.php?caca=1&mierda=2" />',
- '<img src="http://blablabla.com/index.php?caca=1&mierda=2" altibajo="caca">',
+ '<a href="http://blablabla.com/index.php?foo=1&bar=2">bla bla',
+ '<a href="http://blablabla.com/index.php?foo=1&bar=2">bla bla </as>',
+ '<a href="http://blablabla.com/index.php?foo=1&bar=2" taitle="foo">bla bla </a>',
+ '<a href="http://blablabla.com/index.php?foo=1&bar=2" taitle="foo">bla bla </a>',
+ '<a href="http://blablabla.com/index.php?foo=1&bar=2" title="foo" de la vaca>bla bla <a>',
+ '<img sorcerer="http://blablabla.com/index.php?foo=1&bar=2" />',
+ '<img src="http://blablabla.com/index.php?foo=1&bar=2" altibajo="foo">',
)
xss = (
Modified: trunk/frontend-web/parser_urls.py
==============================================================================
--- trunk/frontend-web/parser_urls.py (original)
+++ trunk/frontend-web/parser_urls.py Wed Jul 4 00:51:36 2007
@@ -23,32 +23,32 @@
import unittest
class Test(unittest.TestCase):
urls = (
- 'http://perseverantia.com',
- 'http://perseverantia.com/',
- 'http://perseverantia.com/caca/',
- 'http://perseverantia.com/caca/de/la/vaca',
- 'http://perseverantia.com/caca?mierda=grande',
- 'http://perseverantia.com/caca?mierda=pa&ti&comerla',
- 'http://www.perseverantia.com',
- 'http://www.www.perseverantia.com',
- 'http://buh.bih.bah.beh.perseverantia.com',
+ 'http://example.com',
+ 'http://example.com/',
+ 'http://example.com/foo/',
+ 'http://example.com/foo/bar/baz/gazonk',
+ 'http://example.com/foo?bar=baz',
+ 'http://example.com/foo?bar=baz&gazonk&gadaf',
+ 'http://www.example.com',
+ 'http://www.www.example.com',
+ 'http://buh.bih.bah.beh.example.com',
)
badurls = (
- 'htp://perseverantia.com',
- 'http:/perseverantia.com',
- 'http//perseverantia.com',
- 'http/perseverantia.com',
- 'http://perseverantia.c/',
- 'http://perseverantia.c/',
+ 'htp://example.com',
+ 'http:/example.com',
+ 'http//example.com',
+ 'http/example.com',
+ 'http://example.c/',
+ 'http://example.c/',
'http://.com',
- 'hattp://perseverantia.comememela',
+ 'hattp://example.comcomcom',
)
def testConversion(self):
- retval, tokens = parse("http://perseverantia.com")
+ retval, tokens = parse("http://example.com")
if retval:
self.fail()
- self.assertEqual(tokens[0][1], """<a href="http://perseverantia.com" title="http://perseverantia.com">http://perseverantia.com</a>""")
+ self.assertEqual(tokens[0][1], """<a href="http://example.com" title="http://example.com">http://example.com</a>""")
def testURLbad(self):
import re
@@ -56,11 +56,11 @@
for i in self.badurls:
self.failIf(regexp.findall(i))
import random
- rnd = random.sample("""?=)(/&%$"!'0987654321+-.,..,;:_"**$caca """,10)
+ rnd = random.sample("""?=)(/&%$"!'0987654321+-.,..,;:_"**$foo """,10)
self.failIf(regexp.findall("%s%s%s" % (rnd, i, rnd)))
for i in self.urls:
import random
- rnd = random.sample("""?=)(/&%$"!'0987654321+-.,..,;:_"**$caca """,10)
+ rnd = random.sample("""?=)(/&%$"!'0987654321+-.,..,;:_"**$foo """,10)
self.failIf(regexp.findall("%s%s%s" % (rnd, i, rnd)))
def testURLok(self):
@@ -69,7 +69,7 @@
for i in self.urls:
self.assert_(regexp.findall(i))
import random
- rnd = random.sample("""?=)(/&%$"!'0987654321+-.,..,;:_"**$%caca """,10)
+ rnd = random.sample("""?=)(/&%$"!'0987654321+-.,..,;:_"**$%foo """,10)
self.assert_(regexp.findall("%s %s %s" % (rnd, i, rnd)))
Modified: trunk/frontend-web/parsers.py
==============================================================================
--- trunk/frontend-web/parsers.py (original)
+++ trunk/frontend-web/parsers.py Wed Jul 4 00:51:36 2007
@@ -46,7 +46,7 @@
('[url="http://example.org/uno&dos"]el & texto[/url]', '<a href="http://example.org/uno&dos">el &amp; texto</a>'),
('[url="http://example.org/uno&dos"]el "" texto[/url]', '<a href="http://example.org/uno&dos">el "" texto</a>'),
('[url="http://example.org/uno&dos"]el "" texto[/url]', '<a href="http://example.org/uno&dos">el "" texto</a>'),
- ('http://caca.com [url="http://example.org/uno&dos"]el "" texto[/url]', '<a href="http://caca.com" title="http://caca.com">http://caca.com</a> <a href="http://example.org/uno&dos">el "" texto</a>'),
+ ('http://example.com [url="http://example.org/uno&dos"]el "" texto[/url]', '<a href="http://example.com" title="http://example.com">http://example.com</a> <a href="http://example.org/uno&dos">el "" texto</a>'),
)
incorrect = (
'<a>paco<a>luis</a>manolo</a>ringesvinto',
@@ -59,7 +59,7 @@
global allow_errors
allow_errors = False
for code in self.incorrect:
- retval, caca = convert_to_html(code)
+ retval, dummy = convert_to_html(code)
assert retval
def testCorrectCode(self):
@@ -72,7 +72,7 @@
self.assertEqual(html, result)
if __name__ == "__main__":
-# test1 = parser_html.TestHTML
-# test2 = parser_bbcode.TestBBCode
+ test1 = parser_html.TestHTML
+ test2 = parser_bbcode.TestBBCode
import unittest
unittest.main()
More information about the cpif
mailing list