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
4341e54d
Kaydet (Commit)
4341e54d
authored
Nis 24, 2010
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#7507: quote "!" in pipes.quote(); it is a special character for some shells.
üst
f8bff488
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
16 deletions
+12
-16
pipes.py
Lib/pipes.py
+6
-11
test_pipes.py
Lib/test/test_pipes.py
+4
-5
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/pipes.py
Dosyayı görüntüle @
4341e54d
...
@@ -263,11 +263,11 @@ def makepipeline(infile, steps, outfile):
...
@@ -263,11 +263,11 @@ def makepipeline(infile, steps, outfile):
# Reliably quote a string as a single argument for /bin/sh
# Reliably quote a string as a single argument for /bin/sh
_safechars
=
string
.
ascii_letters
+
string
.
digits
+
'!@
%
_-+=:,./'
# Safe unquoted
# Safe unquoted
_
funnychars
=
'"`$
\\
'
# Unsafe inside "double quotes"
_
safechars
=
frozenset
(
string
.
ascii_letters
+
string
.
digits
+
'@
%
_-+=:,./'
)
def
quote
(
file
):
def
quote
(
file
):
''' return a shell-escaped version of the file string '''
"""Return a shell-escaped version of the file string."""
for
c
in
file
:
for
c
in
file
:
if
c
not
in
_safechars
:
if
c
not
in
_safechars
:
break
break
...
@@ -275,11 +275,6 @@ def quote(file):
...
@@ -275,11 +275,6 @@ def quote(file):
if
not
file
:
if
not
file
:
return
"''"
return
"''"
return
file
return
file
if
'
\'
'
not
in
file
:
# use single quotes, and put single quotes into double quotes
return
'
\'
'
+
file
+
'
\'
'
# the string $'b is then quoted as '$'"'"'b'
res
=
''
return
"'"
+
file
.
replace
(
"'"
,
"'
\"
'
\"
'"
)
+
"'"
for
c
in
file
:
if
c
in
_funnychars
:
c
=
'
\\
'
+
c
res
=
res
+
c
return
'"'
+
res
+
'"'
Lib/test/test_pipes.py
Dosyayı görüntüle @
4341e54d
...
@@ -64,9 +64,10 @@ class SimplePipeTests(unittest.TestCase):
...
@@ -64,9 +64,10 @@ class SimplePipeTests(unittest.TestCase):
self
.
assertEqual
(
open
(
TESTFN
)
.
read
(),
d
)
self
.
assertEqual
(
open
(
TESTFN
)
.
read
(),
d
)
def
testQuoting
(
self
):
def
testQuoting
(
self
):
safeunquoted
=
string
.
ascii_letters
+
string
.
digits
+
'
!
@
%
_-+=:,./'
safeunquoted
=
string
.
ascii_letters
+
string
.
digits
+
'@
%
_-+=:,./'
unsafe
=
'"`$
\\
'
unsafe
=
'"`$
\\
!
'
self
.
assertEqual
(
pipes
.
quote
(
''
),
"''"
)
self
.
assertEqual
(
pipes
.
quote
(
safeunquoted
),
safeunquoted
)
self
.
assertEqual
(
pipes
.
quote
(
safeunquoted
),
safeunquoted
)
self
.
assertEqual
(
pipes
.
quote
(
'test file name'
),
"'test file name'"
)
self
.
assertEqual
(
pipes
.
quote
(
'test file name'
),
"'test file name'"
)
for
u
in
unsafe
:
for
u
in
unsafe
:
...
@@ -74,9 +75,7 @@ class SimplePipeTests(unittest.TestCase):
...
@@ -74,9 +75,7 @@ class SimplePipeTests(unittest.TestCase):
"'test
%
sname'"
%
u
)
"'test
%
sname'"
%
u
)
for
u
in
unsafe
:
for
u
in
unsafe
:
self
.
assertEqual
(
pipes
.
quote
(
"test
%
s'name'"
%
u
),
self
.
assertEqual
(
pipes
.
quote
(
"test
%
s'name'"
%
u
),
'"test
\\
%
s
\'
name
\'
"'
%
u
)
"'test
%
s'
\"
'
\"
'name'
\"
'
\"
''"
%
u
)
self
.
assertEqual
(
pipes
.
quote
(
''
),
"''"
)
def
testRepr
(
self
):
def
testRepr
(
self
):
t
=
pipes
.
Template
()
t
=
pipes
.
Template
()
...
...
Misc/NEWS
Dosyayı görüntüle @
4341e54d
...
@@ -25,6 +25,8 @@ Core and Builtins
...
@@ -25,6 +25,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #7507: Quote "!" in pipes.quote(); it is special to some shells.
- Issue #5238: Calling makefile() on an SSL object would prevent the
- Issue #5238: Calling makefile() on an SSL object would prevent the
underlying socket from being closed until all objects get truely destroyed.
underlying socket from being closed until all objects get truely destroyed.
...
...
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