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
21cf5ee6
Kaydet (Commit)
21cf5ee6
authored
Nis 12, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#5741: dont disallow double percent signs in SafeConfigParser.set() keys.
üst
3295eed6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
ConfigParser.py
Lib/ConfigParser.py
+4
-4
test_cfgparser.py
Lib/test/test_cfgparser.py
+4
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/ConfigParser.py
Dosyayı görüntüle @
21cf5ee6
...
...
@@ -620,7 +620,6 @@ class SafeConfigParser(ConfigParser):
return
''
.
join
(
L
)
_interpvar_re
=
re
.
compile
(
r"
%
\(([^)]+)\)s"
)
_badpercent_re
=
re
.
compile
(
r"
%
[^
%
]|
%
$"
)
def
_interpolate_some
(
self
,
option
,
accum
,
rest
,
section
,
map
,
depth
):
if
depth
>
MAX_INTERPOLATION_DEPTH
:
...
...
@@ -667,9 +666,10 @@ class SafeConfigParser(ConfigParser):
# check for bad percent signs:
# first, replace all "good" interpolations
tmp_value
=
self
.
_interpvar_re
.
sub
(
''
,
value
)
tmp_value
=
tmp_value
.
replace
(
'
%%
'
,
''
)
# then, check if there's a lone percent sign left
m
=
self
.
_badpercent_re
.
search
(
tmp_value
)
if
m
:
percent_index
=
tmp_value
.
find
(
'
%
'
)
if
percent_index
!=
-
1
:
raise
ValueError
(
"invalid interpolation syntax in
%
r at "
"position
%
d"
%
(
value
,
m
.
start
()
))
"position
%
d"
%
(
value
,
percent_index
))
ConfigParser
.
set
(
self
,
section
,
option
,
value
)
Lib/test/test_cfgparser.py
Dosyayı görüntüle @
21cf5ee6
...
...
@@ -434,6 +434,10 @@ class SafeConfigParserTestCase(ConfigParserTestCase):
self
.
assertEqual
(
cf
.
get
(
'sect'
,
"option1"
),
"foo"
)
# bug #5741: double percents are *not* malformed
cf
.
set
(
"sect"
,
"option2"
,
"foo
%%
bar"
)
self
.
assertEqual
(
cf
.
get
(
"sect"
,
"option2"
),
"foo
%
bar"
)
def
test_set_nonstring_types
(
self
):
cf
=
self
.
fromstring
(
"[sect]
\n
"
"option1=foo
\n
"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
21cf5ee6
...
...
@@ -221,6 +221,9 @@ Core and Builtins
Library
-------
- Issue #5741: don't disallow "%%" (which is an escape for "%") when setting
a value in SafeConfigParser.
- Issue #5732: added a new command in Distutils: check.
- Issue #5731: Distutils bdist_wininst no longer worked on non-Windows
...
...
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