Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b0c75a7d
Kaydet (Commit)
b0c75a7d
authored
Şub 16, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #9669: Protect re against infinite loops on zero-width matching in
non-greedy repeat. Patch by Matthew Barnett.
üst
f8def28f
fa468169
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
test_re.py
Lib/test/test_re.py
+9
-0
NEWS
Misc/NEWS
+3
-0
_sre.c
Modules/_sre.c
+7
-2
No files found.
Lib/test/test_re.py
Dosyayı görüntüle @
b0c75a7d
...
...
@@ -681,6 +681,15 @@ class ReTests(unittest.TestCase):
self
.
assertEqual
(
re
.
match
(
'(x)*y'
,
50000
*
'x'
+
'y'
)
.
group
(
1
),
'x'
)
self
.
assertEqual
(
re
.
match
(
'(x)*?y'
,
50000
*
'x'
+
'y'
)
.
group
(
1
),
'x'
)
def
test_unlimited_zero_width_repeat
(
self
):
# Issue #9669
self
.
assertIsNone
(
re
.
match
(
r'(?:a?)*y'
,
'z'
))
self
.
assertIsNone
(
re
.
match
(
r'(?:a?)+y'
,
'z'
))
self
.
assertIsNone
(
re
.
match
(
r'(?:a?){2,}y'
,
'z'
))
self
.
assertIsNone
(
re
.
match
(
r'(?:a?)*?y'
,
'z'
))
self
.
assertIsNone
(
re
.
match
(
r'(?:a?)+?y'
,
'z'
))
self
.
assertIsNone
(
re
.
match
(
r'(?:a?){2,}?y'
,
'z'
))
def
test_scanner
(
self
):
def
s_ident
(
scanner
,
token
):
return
token
def
s_operator
(
scanner
,
token
):
return
"op
%
s"
%
token
...
...
Misc/NEWS
Dosyayı görüntüle @
b0c75a7d
...
...
@@ -178,6 +178,9 @@ Core and Builtins
Library
-------
- Issue #9669: Protect re against infinite loops on zero-width matching in
non-greedy repeat. Patch by Matthew Barnett.
- Issue #13169: The maximal repetition number in a regular expression has been
increased from 65534 to 2147483647 (on 32-bit platform) or 4294967294 (on
64-bit).
...
...
Modules/_sre.c
Dosyayı görüntüle @
b0c75a7d
...
...
@@ -1272,13 +1272,18 @@ entrance:
LASTMARK_RESTORE
();
if
(
ctx
->
count
>=
ctx
->
u
.
rep
->
pattern
[
2
]
&&
ctx
->
u
.
rep
->
pattern
[
2
]
!=
SRE_MAXREPEAT
)
if
((
ctx
->
count
>=
ctx
->
u
.
rep
->
pattern
[
2
]
&&
ctx
->
u
.
rep
->
pattern
[
2
]
!=
SRE_MAXREPEAT
)
||
state
->
ptr
==
ctx
->
u
.
rep
->
last_ptr
)
RETURN_FAILURE
;
ctx
->
u
.
rep
->
count
=
ctx
->
count
;
/* zero-width match protection */
DATA_PUSH
(
&
ctx
->
u
.
rep
->
last_ptr
);
ctx
->
u
.
rep
->
last_ptr
=
state
->
ptr
;
DO_JUMP
(
JUMP_MIN_UNTIL_3
,
jump_min_until_3
,
ctx
->
u
.
rep
->
pattern
+
3
);
DATA_POP
(
&
ctx
->
u
.
rep
->
last_ptr
);
if
(
ret
)
{
RETURN_ON_ERROR
(
ret
);
RETURN_SUCCESS
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment