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
8112ea23
Kaydet (Commit)
8112ea23
authored
Eyl 24, 2012
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #16012: Fix a regression in pyexpat. The parser's UseForeignDTD()
method doesn't require an argument again.
üst
cadff70b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
2 deletions
+61
-2
test_pyexpat.py
Lib/test/test_pyexpat.py
+54
-1
NEWS
Misc/NEWS
+6
-0
pyexpat.c
Modules/pyexpat.c
+1
-1
No files found.
Lib/test/test_pyexpat.py
Dosyayı görüntüle @
8112ea23
...
...
@@ -588,6 +588,58 @@ class MalformedInputText(unittest.TestCase):
except
expat
.
ExpatError
as
e
:
self
.
assertEqual
(
str
(
e
),
'XML declaration not well-formed: line 1, column 14'
)
class
ForeignDTDTests
(
unittest
.
TestCase
):
"""
Tests for the UseForeignDTD method of expat parser objects.
"""
def
test_use_foreign_dtd
(
self
):
"""
If UseForeignDTD is passed True and a document without an external
entity reference is parsed, ExternalEntityRefHandler is first called
with None for the public and system ids.
"""
handler_call_args
=
[]
def
resolve_entity
(
context
,
base
,
system_id
,
public_id
):
handler_call_args
.
append
((
public_id
,
system_id
))
return
1
parser
=
expat
.
ParserCreate
()
parser
.
UseForeignDTD
(
True
)
parser
.
SetParamEntityParsing
(
expat
.
XML_PARAM_ENTITY_PARSING_ALWAYS
)
parser
.
ExternalEntityRefHandler
=
resolve_entity
parser
.
Parse
(
"<?xml version='1.0'?><element/>"
)
self
.
assertEqual
(
handler_call_args
,
[(
None
,
None
)])
# test UseForeignDTD() is equal to UseForeignDTD(True)
handler_call_args
[:]
=
[]
parser
=
expat
.
ParserCreate
()
parser
.
UseForeignDTD
()
parser
.
SetParamEntityParsing
(
expat
.
XML_PARAM_ENTITY_PARSING_ALWAYS
)
parser
.
ExternalEntityRefHandler
=
resolve_entity
parser
.
Parse
(
"<?xml version='1.0'?><element/>"
)
self
.
assertEqual
(
handler_call_args
,
[(
None
,
None
)])
def
test_ignore_use_foreign_dtd
(
self
):
"""
If UseForeignDTD is passed True and a document with an external
entity reference is parsed, ExternalEntityRefHandler is called with
the public and system ids from the document.
"""
handler_call_args
=
[]
def
resolve_entity
(
context
,
base
,
system_id
,
public_id
):
handler_call_args
.
append
((
public_id
,
system_id
))
return
1
parser
=
expat
.
ParserCreate
()
parser
.
UseForeignDTD
(
True
)
parser
.
SetParamEntityParsing
(
expat
.
XML_PARAM_ENTITY_PARSING_ALWAYS
)
parser
.
ExternalEntityRefHandler
=
resolve_entity
parser
.
Parse
(
"<?xml version='1.0'?><!DOCTYPE foo PUBLIC 'bar' 'baz'><element/>"
)
self
.
assertEqual
(
handler_call_args
,
[(
"bar"
,
"baz"
)])
def
test_main
():
run_unittest
(
SetAttributeTest
,
ParseTest
,
...
...
@@ -598,7 +650,8 @@ def test_main():
PositionTest
,
sf1296433Test
,
ChardataBufferTest
,
MalformedInputText
)
MalformedInputText
,
ForeignDTDTests
)
if
__name__
==
"__main__"
:
test_main
()
Misc/NEWS
Dosyayı görüntüle @
8112ea23
...
...
@@ -379,6 +379,12 @@ Library
- Issue #6884: Fix long-standing bugs with MANIFEST.in parsing in distutils
on Windows.
Extension Modules
-----------------
- Issue #16012: Fix a regression in pyexpat. The parser'
s
UseForeignDTD
()
method
doesn
't require an argument again.
Tests
-----
...
...
Modules/pyexpat.c
Dosyayı görüntüle @
8112ea23
...
...
@@ -1176,7 +1176,7 @@ xmlparse_UseForeignDTD(xmlparseobject *self, PyObject *args)
PyObject
*
flagobj
=
NULL
;
int
flag
=
1
;
enum
XML_Error
rc
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:UseForeignDTD"
,
&
flagobj
))
if
(
!
PyArg_ParseTuple
(
args
,
"
|
O:UseForeignDTD"
,
&
flagobj
))
return
NULL
;
if
(
flagobj
!=
NULL
)
{
flag
=
PyObject_IsTrue
(
flagobj
);
...
...
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