-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
bpo-35859: fix bugs in re engine #12427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
f738245
0d1e658
cbc10fc
1043bc6
8e1407e
5772bb1
738ed31
abde0e9
32b9797
7ff501b
2b359f3
3ae8e69
5b3e43d
c84d7ed
b00c6e3
d671c44
ccbdb92
18bb63b
e084e64
94a4fdc
49d00d2
785d9bf
3fe33a8
d6c07b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
re module, fix a few bugs about capturing group. In rare cases, capturing | ||
group gets an incorrect string. Patch by Ma Lin. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,14 @@ | |
/* size of a code word (must be unsigned short or larger, and | ||
large enough to hold a UCS4 character) */ | ||
#define SRE_CODE Py_UCS4 | ||
|
||
/* SRE_MAXGROUPS is 1,073,741,823 */ | ||
#define SRE_MAXGROUPS INT_MAX / 2 | ||
|
||
#if SIZEOF_SIZE_T > 4 | ||
# define SRE_MAXREPEAT (~(SRE_CODE)0) | ||
# define SRE_MAXGROUPS ((~(SRE_CODE)0) / 2) | ||
#else | ||
# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX) | ||
# define SRE_MAXGROUPS ((SRE_CODE)PY_SSIZE_T_MAX / SIZEOF_SIZE_T / 2) | ||
#endif | ||
|
||
typedef struct { | ||
|
@@ -71,18 +73,18 @@ typedef struct { | |
Py_ssize_t pos, endpos; | ||
int isbytes; | ||
int charsize; /* character size */ | ||
/* current repeat context */ | ||
SRE_REPEAT *repeat; | ||
/* registers */ | ||
Py_ssize_t lastindex; | ||
Py_ssize_t lastmark; | ||
int32_t lastmark; | ||
int32_t lastindex; | ||
|
||
const void** mark; | ||
int match_all; | ||
int must_advance; | ||
/* dynamically allocated stuff */ | ||
char* data_stack; | ||
size_t data_stack_size; | ||
size_t data_stack_base; | ||
/* current repeat context */ | ||
SRE_REPEAT *repeat; | ||
} SRE_STATE; | ||
|
||
typedef struct { | ||
|
Uh oh!
There was an error while loading. Please reload this page.