]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Escape locale data for regex metacharacters.
authorBrett Cannon <bcannon@gmail.com>
Wed, 6 Oct 2004 02:16:45 +0000 (02:16 +0000)
committerBrett Cannon <bcannon@gmail.com>
Wed, 6 Oct 2004 02:16:45 +0000 (02:16 +0000)
Closes bug #1039270.

Lib/_strptime.py
Misc/NEWS

index 1d05869f0d7216c5e60153de591f838c9fee49ea..cc578305ad98ddde590a21cfa8b08c5c23373259 100644 (file)
@@ -18,6 +18,7 @@ import locale
 import calendar
 from re import compile as re_compile
 from re import IGNORECASE
+from re import escape as re_escape
 from datetime import date as datetime_date
 
 __author__ = "Brett Cannon"
@@ -367,7 +368,7 @@ class TimeRE(dict):
         else:
             return ''
         to_convert.sort(sorter)
-        regex = '|'.join(to_convert)
+        regex = '|'.join([re_escape(stuff) for stuff in to_convert])
         regex = '(?P<%s>%s' % (directive, regex)
         return '%s)' % regex
 
index 6c748f9539921bb9cf774d17807af1efeef650b5..15b6b7f7b129ad455e46c8e79e0335bccdcc6963 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -53,6 +53,8 @@ Extension modules
 Library
 -------
 
+- Bug #1039270: Locale data is now escaped for regex metacharacters.
+
 - Bug #807871: Fix tkMessageBox.askyesno result.
 
 - Patch #1014992: In tarfile.readline, never return more than a line.