Commit a1a96235 authored by Andreas Jung's avatar Andreas Jung

- Collector #631: Image URLs in StructuredText containing port

        numbers were not rendered correctly
parent 53a2e5d2
...@@ -46,6 +46,9 @@ Zope Changes ...@@ -46,6 +46,9 @@ Zope Changes
Bugs fixed Bugs fixed
- Collector #631: Image URLs in StructuredText containing port
numbers were not rendered correctly
- Collector #1498: Don't choke on malformed cookies. Cookies of - Collector #1498: Don't choke on malformed cookies. Cookies of
the form "foo=bar; hmm; baz=gee" will give an empty value for the form "foo=bar; hmm; baz=gee" will give an empty value for
'hmm' instead of silently discarding it and the rest of the 'hmm' instead of silently discarding it and the rest of the
......
...@@ -22,39 +22,15 @@ class DocumentWithImages(DocumentClass): ...@@ -22,39 +22,15 @@ class DocumentWithImages(DocumentClass):
""" """
text_types = [ text_types = [
'doc_img', 'doc_img',
] + DocumentClass.text_types ] + DocumentClass.text_types
def doc_img( def doc_img(
self, s, 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,
expr2=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+):([a-zA-Z0-9_\-.:/;,\n\~]+)').search
): ):
r = expr2(s)
if r:
# Warning: the regex are getting confused when the string after :img:
# is an URL containing ":" (Collector #2276)
# Ugly workaround: check if have an absolute URL here. Not a cool solution,
# but it works !
if not r.group(2) in ['http','file','ftp']:
startt, endt = r.span(1)
startk, endk = r.span(2)
starth, endh = r.span(3)
start, end = r.span()
key = s[startk:endk]
return (StructuredTextImage(s[startt:endt], href=s[starth:endh], key=s[startk:endk]),
start, end)
r=expr1(s) r=expr1(s)
if r: if r:
startt, endt = r.span(1) startt, endt = r.span(1)
......
...@@ -210,6 +210,13 @@ class BasicTests(unittest.TestCase): ...@@ -210,6 +210,13 @@ class BasicTests(unittest.TestCase):
'<code>"literal":http://www.zope.org/.</code>') '<code>"literal":http://www.zope.org/.</code>')
def testImgLink(self):
self._test('"foo":img:http://www.zope.org/bar.gif',
'<p><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" />')
def XXXtestUnicodeContent(self): def XXXtestUnicodeContent(self):
# This fails because ST uses the default locale to get "letters" # This fails because ST uses the default locale to get "letters"
# whereas it should use \w+ and re.U if the string is Unicode. # whereas it should use \w+ and re.U if the string is Unicode.
......
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