This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: fix for several sre escaping bugs (fixes #776311)
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: niemeyer Nosy List: loewis, mkc, niemeyer
Priority: normal Keywords: patch

Created on 2004-08-29 00:19 by mkc, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mkc-patch.gz mkc, 2004-08-29 00:19 the patch
sre.patch niemeyer, 2004-09-03 17:18 Applied patch.
Messages (6)
msg46801 - (view) Author: Mike Coleman (mkc) Date: 2004-08-29 00:19
This patch fixes a number of escaping bugs in sre (the
re module).  The most serious is an infinite loop in
the parser, which is what the submitter of bug #776311
was seeing.  Another allows octal escapes to have an
arbitrary number of digits--the doc didn't quite
exclude this, but it's clearly the wrong thing (cf.
string literals).  There are others--see the test cases.
msg46802 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-08-29 16:01
Logged In: YES 
user_id=21627

Gustavo, can you take a look? If not, please unassign.
msg46803 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2004-09-02 21:51
Logged In: YES 
user_id=7887

Of course! I'll be reviewing it offline and get back shortly. 
 
Thanks for assigning it to me! 
msg46804 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2004-09-03 17:18
Logged In: YES 
user_id=7887

Applied as: 
 
Lib/sre_parse.py: 1.62 
Lib/test/test_re.py: 1.51 
Doc/lib/libre.tex: 1.109 
 
It was a little bit modified to adapt to the current CVS version. 
 
I've also reimplemented the logic of numeric escaping with a logic 
similar to what is used in _escape() function, making it a little bit 
faster and removing the need for the external function. 
 
I'm attaching the applied patch for reference. Please, let me know if 
you have any comments. 
 
Thanks a lot for the patch! 
 
msg46805 - (view) Author: Mike Coleman (mkc) Date: 2004-09-03 20:00
Logged In: YES 
user_id=555

Gustavo, it looks better than my patch.

Two very minor comments:
- The s/wildcare/wildcard/ fix to _sre.c got dropped?
- In this expression, you're checking the first digit, then
the third, then the second.  I'd check them in order, for
readability.

       c in OCTDIGITS and s.next in OCTDIGITS and this[2] in
OCTDIGITS

As I said, very minor.  Thanks for the quick review/apply!
msg46806 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2004-09-03 20:19
Logged In: YES 
user_id=7887

I included the comment typo fix on _sre.c into another patch I had 
to apply. Sorry for not mentioning it. 
 
I just reordered these entries as you suggested. 
 
Thanks again! 
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40840
2004-08-29 00:19:07mkccreate