Commit eb9f1477 authored by Chris McDonough's avatar Chris McDonough

DocumentClass was changed to support alternate locates a while back. One of...

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.
parent 3304cb5d
......@@ -85,8 +85,7 @@
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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 @@ class DocumentClass:
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,
......
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