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
4781b072
Kaydet (Commit)
4781b072
authored
Haz 29, 2000
tarafından
Fredrik Lundh
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
- make sure group names are valid identifiers
(closes the "SRE: symbolic reference" bug)
üst
75f2d675
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
sre_parse.py
Lib/sre_parse.py
+25
-5
No files found.
Lib/sre_parse.py
Dosyayı görüntüle @
4781b072
...
...
@@ -168,6 +168,24 @@ class Tokenizer:
self
.
next
=
self
.
__next
()
return
this
def
isident
(
char
):
return
"a"
<=
char
<=
"z"
or
"A"
<=
char
<=
"Z"
or
char
==
"_"
def
isdigit
(
char
):
return
"0"
<=
char
<=
"9"
def
isname
(
name
):
# check that group name is a valid string
# FIXME: <fl> this code is really lame. should use a regular
# expression instead, but I seem to have certain bootstrapping
# problems here ;-)
if
not
isident
(
name
[
0
]):
return
0
for
char
in
name
:
if
not
isident
(
char
)
and
not
isdigit
(
char
):
return
0
return
1
def
_group
(
escape
,
state
):
# check if the escape string represents a valid group
try
:
...
...
@@ -418,9 +436,10 @@ def _parse(source, state, flags=0):
raise
error
,
"unterminated name"
if
char
==
">"
:
break
# FIXME: check for valid character
name
=
name
+
char
group
=
1
if
not
isname
(
name
):
raise
error
,
"illegal character in group name"
elif
source
.
match
(
"="
):
# named backreference
raise
error
,
"not yet implemented"
...
...
@@ -522,20 +541,21 @@ def parse_template(source, pattern):
while
1
:
char
=
s
.
get
()
if
char
is
None
:
raise
error
,
"unterminated
index
"
raise
error
,
"unterminated
group name
"
if
char
==
">"
:
break
# FIXME: check for valid character
name
=
name
+
char
if
not
name
:
raise
error
,
"bad
index
"
raise
error
,
"bad
group name
"
try
:
index
=
int
(
name
)
except
ValueError
:
if
not
isname
(
name
):
raise
error
,
"illegal character in group name"
try
:
index
=
pattern
.
groupindex
[
name
]
except
KeyError
:
raise
IndexError
,
"unknown
index
"
raise
IndexError
,
"unknown
group name
"
a
((
MARK
,
index
))
elif
len
(
this
)
>
1
and
this
[
1
]
in
DIGITS
:
while
s
.
next
in
DIGITS
:
...
...
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