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