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
55e092f5
Kaydet (Commit)
55e092f5
authored
Eki 19, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #19279: UTF-7 decoder no more produces illegal strings.
üst
f19a6ef2
35804e4c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
test_codecs.py
Lib/test/test_codecs.py
+30
-0
NEWS
Misc/NEWS
+2
-0
unicodeobject.c
Objects/unicodeobject.c
+2
-0
No files found.
Lib/test/test_codecs.py
Dosyayı görüntüle @
55e092f5
...
...
@@ -820,6 +820,36 @@ class UTF7Test(ReadTest, unittest.TestCase):
]
)
def
test_errors
(
self
):
tests
=
[
(
b
'a
\xff
b'
,
'a
\ufffd
b'
),
(
b
'a+IK'
,
'a
\ufffd
'
),
(
b
'a+IK-b'
,
'a
\ufffd
b'
),
(
b
'a+IK,b'
,
'a
\ufffd
b'
),
(
b
'a+IKx'
,
'a
\u20ac\ufffd
'
),
(
b
'a+IKx-b'
,
'a
\u20ac\ufffd
b'
),
(
b
'a+IKwgr'
,
'a
\u20ac\ufffd
'
),
(
b
'a+IKwgr-b'
,
'a
\u20ac\ufffd
b'
),
(
b
'a+IKwgr,'
,
'a
\u20ac\ufffd
'
),
(
b
'a+IKwgr,-b'
,
'a
\u20ac\ufffd
-b'
),
(
b
'a+IKwgrB'
,
'a
\u20ac\u20ac\ufffd
'
),
(
b
'a+IKwgrB-b'
,
'a
\u20ac\u20ac\ufffd
b'
),
(
b
'a+/,+IKw-b'
,
'a
\ufffd\u20ac
b'
),
(
b
'a+//,+IKw-b'
,
'a
\ufffd\u20ac
b'
),
(
b
'a+///,+IKw-b'
,
'a
\uffff\ufffd\u20ac
b'
),
(
b
'a+////,+IKw-b'
,
'a
\uffff\ufffd\u20ac
b'
),
]
for
raw
,
expected
in
tests
:
with
self
.
subTest
(
raw
=
raw
):
self
.
assertRaises
(
UnicodeDecodeError
,
codecs
.
utf_7_decode
,
raw
,
'strict'
,
True
)
self
.
assertEqual
(
raw
.
decode
(
'utf-7'
,
'replace'
),
expected
)
def
test_nonbmp
(
self
):
self
.
assertEqual
(
'
\U000104A0
'
.
encode
(
self
.
encoding
),
b
'+2AHcoA-'
)
self
.
assertEqual
(
'
\ud801\udca0
'
.
encode
(
self
.
encoding
),
b
'+2AHcoA-'
)
self
.
assertEqual
(
b
'+2AHcoA-'
.
decode
(
self
.
encoding
),
'
\U000104A0
'
)
class
UTF16ExTest
(
unittest
.
TestCase
):
def
test_errors
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
55e092f5
...
...
@@ -10,6 +10,8 @@ Projected release date: 2013-10-20
Core and Builtins
-----------------
- Issue #19279: UTF-7 decoder no more produces illegal strings.
- Issue #16612: Add "Argument Clinic", a compile-time preprocessor for
C files to generate argument parsing code. (See PEP 436.)
...
...
Objects/unicodeobject.c
Dosyayı görüntüle @
55e092f5
...
...
@@ -4341,6 +4341,7 @@ PyUnicode_DecodeUTF7Stateful(const char *s,
Py_UCS4 outCh = (Py_UCS4)(base64buffer >> (base64bits-16));
base64bits -= 16;
base64buffer &= (1 << base64bits) - 1; /* clear high bits */
assert(outCh <= 0xffff);
if (surrogate) {
/* expecting a second surrogate */
if (Py_UNICODE_IS_LOW_SURROGATE(outCh)) {
...
...
@@ -4408,6 +4409,7 @@ PyUnicode_DecodeUTF7Stateful(const char *s,
inShift = 1;
shiftOutStart = writer.pos;
base64bits = 0;
base64buffer = 0;
}
}
else if (DECODE_DIRECT(ch)) { /* character decodes as itself */
...
...
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