[Zope-Checkins] CVS: Zope2 - DocumentClass.py:1.23

chrism@serenade.digicool.com chrism@serenade.digicool.com
Fri, 22 Jun 2001 23:21:39 -0400


Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory serenade:/home/chrism/BackTalk/lib/python/StructuredText

Modified Files:
	DocumentClass.py 
Log Message:
DocumentClass was changed to support alternate locates a while back.  One of the ways in which this was done was to use string.punctuation with locale support turned on, stuffing the results into regular expressions.

Unfortunately, the insertion of the punctuation into regular expressions was completely literal.  This meant that, depending on locale, a regex could take on a completely different semantic due to the fact that it could include "]", "?", etc.  At times, this could cause a segmentation fault if a nonsensical generated regex was especially juicy.

I took out the code which localized punctuation, although the code which localizes letters is still there.



--- Updated File DocumentClass.py in package Zope2 --
--- DocumentClass.py	2001/06/19 03:32:12	1.22
+++ DocumentClass.py	2001/06/23 03:21:39	1.23
@@ -85,9 +85,8 @@
 
 import re, ST, STDOM
 from string import split, join, replace, expandtabs, strip, find, rstrip
-from STletters import *
+from STletters import letters
 
-
 StringType=type('')
 ListType=type([])
 
@@ -840,8 +839,7 @@
            delim=d)
 
     def doc_header(self, paragraph,
-                    expr    = re.compile(r'[ %s0-9.:/,-_*<>\?\'\"]+' % letters).match
-                    ):
+                   expr=re.compile(r'[ %s0-9.:/,-_*<>\?\'\"]+' % letters).match):
         subs=paragraph.getSubparagraphs()
         if not subs: return None
         top=paragraph.getColorizableTexts()[0]
@@ -875,7 +873,7 @@
 
     def doc_emphasize(
         self, s,
-        expr = re.compile(r'\s*\*([ \n%s0-9]+)\*(?!\*|-)' % lettpunc).search
+        expr = re.compile(r'\s*\*([ \n%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search
         ):
 
         r=expr(s)
@@ -922,8 +920,7 @@
     
     def doc_underline(self,
                       s,
-                      expr=re.compile(r"\s+\_([%s0-9\s]+)\_" % lettpunc).search):
-        
+                      expr=re.compile(r"\_([%s0-9\s\.,\?]+)\_" % letters).search):
         result = expr(s)
         if result:
             start,end = result.span(1)
@@ -932,9 +929,9 @@
         else:
             return None
     
-    def doc_strong(self, 
+    def doc_strong(self,
                    s,
-        expr = re.compile(r'\s*\*\*([ \n%s0-9]+)\*\*' % lettpunc).search
+                   expr = re.compile(r'\s*\*([ \n%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search
         ):
 
         r=expr(s)
@@ -945,8 +942,8 @@
            return None
 
     ## Some constants to make the doc_href() regex easier to read.
-    _DQUOTEDTEXT = r'("[%s0-9\n%s]+")'  % (letters,punctuations) ## double quoted text
-    _URL_AND_PUNC = r'([%s0-9_\@%s]+)' % (letters,punctuations) 
+    _DQUOTEDTEXT = r'("[ %s0-9\n\-\.\,\;\(\)\/\:\/\*\']+")' % letters ## double quoted text
+    _URL_AND_PUNC = r'([%s0-9_\@\.\,\?\!\/\:\;\-\#\~]+)' % letters
     _SPACES = r'(\s*)'
     
     def doc_href(self, s,