Commit 113fc84a authored by Andreas Jung's avatar Andreas Jung

- Collector #1750: StructuredText: fixed handling of image URLs

  with query string                                            i
- some more unittests
parent a69fba72
......@@ -29,6 +29,9 @@ Zope Changes
Bugs fixed
- Collector #1750: StructuredText: fixed handling of image URLs
with query string
- Collector #1748: Fixed SIGSEGV in Acquisition
- Hotfix_20050405: classes defined in untrusted code could shadow
......
......@@ -18,19 +18,19 @@ class StructuredTextImage(StructuredTextMarkup):
"A simple embedded image"
class DocumentWithImages(DocumentClass):
"""
"""
""" Document with images """
text_types = [
'doc_img',
] + DocumentClass.text_types
def doc_img(
self, s,
expr1=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+)').search,
expr1=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9%\_\-.:/\?=;,\n\~]+)').search,
):
r=expr1(s)
if r:
startt, endt = r.span(1)
......
......@@ -138,7 +138,7 @@ class BasicTests(unittest.TestCase):
if not isinstance(stxtxt, UnicodeType):
res = HTML(stxtxt,level=1,header=0)
if res.find(expected)==-1:
if not expected in res:
print "Text: ",stxtxt
print "Converted:",res
print "Expected: ",expected
......@@ -148,8 +148,10 @@ class BasicTests(unittest.TestCase):
ustxtxt = stxtxt
else:
ustxtxt = unicode(stxtxt)
res = HTML(ustxtxt,level=1,header=0)
if res.find(expected)==-1:
if not expected in res:
print "Text: ",stxtxt.encode('latin-1')
print "Converted:",res.encode('latin-1')
print "Expected: ",expected.encode('latin-1')
......@@ -210,12 +212,29 @@ class BasicTests(unittest.TestCase):
'<code>"literal":http://www.zope.org/.</code>')
def testLink(self):
self._test('"foo":http://www.zope.org/foo/bar',
'<p><a href="http://www.zope.org/foo/bar">foo</a></p>')
self._test('"foo":http://www.zope.org/foo/bar/%20x',
'<p><a href="http://www.zope.org/foo/bar/%20x">foo</a></p>')
self._test('"foo":http://www.zope.org/foo/bar?arg1=1&arg2=2',
'<p><a href="http://www.zope.org/foo/bar?arg1=1&arg2=2">foo</a></p>')
def testImgLink(self):
self._test('"foo":img:http://www.zope.org/bar.gif',
'<p><img src="http://www.zope.org/bar.gif" alt="foo" />')
'<img src="http://www.zope.org/bar.gif" alt="foo">')
self._test('"foo":img:http://www.zope.org:8080/bar.gif',
'<p><img src="http://www.zope.org:8080/bar.gif" alt="foo" />')
'<img src="http://www.zope.org:8080/bar.gif" alt="foo">')
self._test('"foo":img:http://www.zope.org:8080/foo/bar?arg=1',
'<img src="http://www.zope.org:8080/foo/bar?arg=1" alt="foo">')
self._test('"foo":img:http://www.zope.org:8080/foo/b%20ar?arg=1',
'<img src="http://www.zope.org:8080/foo/b%20ar?arg=1" alt="foo">')
def XXXtestUnicodeContent(self):
# This fails because ST uses the default locale to get "letters"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment