[Zope-Checkins] CVS: Zope2 - DocumentWithImages.py:1.4
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Mon, 4 Jun 2001 14:08:01 -0400
Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory serenade:/tmp/cvs-serv16627
Modified Files:
DocumentWithImages.py
Log Message:
fix for collector #2276. Absolute URLs confused the regex for handling
:img:
--- Updated File DocumentWithImages.py in package Zope2 --
--- DocumentWithImages.py 2001/06/04 17:53:40 1.3
+++ DocumentWithImages.py 2001/06/04 18:08:01 1.4
@@ -108,30 +108,34 @@
expr2=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\-.:/;,\n\~]+):([a-zA-Z0-9\-.:/;,\n\~]+)').search
):
- # Warning: the regex are getting confused when the string after :img:
- # is an URL containing ":" (Collector #2276)
+ 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 !
- r = expr2(s)
+ 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)
if r:
startt, endt = r.span(1)
- startk, endk = r.span(2)
- starth, endh = r.span(3)
+ starth, endh = r.span(2)
start, end = r.span()
- return (StructuredTextImage(s[startt:endt], href=s[starth:endh], key=s[startk:endk]),
+ return (StructuredTextImage(s[startt:endt], href=s[starth:endh]),
start, end)
-
-
- else:
-
- r=expr1(s)
-
- if r:
- startt, endt = r.span(1)
- starth, endh = r.span(2)
- start, end = r.span()
- return (StructuredTextImage(s[startt:endt], href=s[starth:endh]),
- start, end)
- return None
+ return None