Backport of r74429. Not merged/blocked as svnmerge.py is giving me an error and

I don't want to accidentally check in busted svnmerge metadata.
This commit is contained in:
Brett Cannon 2009-08-13 19:45:44 +00:00
parent 9440a4a22c
commit 559eb08861
4 changed files with 25 additions and 3 deletions

View file

@ -559,6 +559,24 @@ class ChardataBufferTest(unittest.TestCase):
parser.Parse(xml2, 1) parser.Parse(xml2, 1)
self.assertEquals(self.n, 4) self.assertEquals(self.n, 4)
class MalformedInputText(unittest.TestCase):
def test1(self):
xml = "\0\r\n"
parser = expat.ParserCreate()
try:
parser.Parse(xml, True)
self.fail()
except expat.ExpatError as e:
self.assertEquals(str(e), 'no element found: line 2, column 1')
def test2(self):
xml = "<?xml version\xc2\x85='1.0'?>\r\n"
parser = expat.ParserCreate()
try:
parser.Parse(xml, True)
self.fail()
except expat.ExpatError as e:
self.assertEquals(str(e), 'XML declaration not well-formed: line 1, column 14')
def test_main(): def test_main():
run_unittest(SetAttributeTest, run_unittest(SetAttributeTest,
@ -569,7 +587,8 @@ def test_main():
HandlerExceptionTest, HandlerExceptionTest,
PositionTest, PositionTest,
sf1296433Test, sf1296433Test,
ChardataBufferTest) ChardataBufferTest,
MalformedInputText)
if __name__ == "__main__": if __name__ == "__main__":
test_main() test_main()

View file

@ -177,6 +177,7 @@ Ismail Donmez
Dima Dorfman Dima Dorfman
Cesar Douady Cesar Douady
Dean Draayer Dean Draayer
Fred L. Drake, Jr.
John DuBois John DuBois
Paul Dubois Paul Dubois
Graham Dumpleton Graham Dumpleton
@ -358,7 +359,6 @@ Irmen de Jong
Lucas de Jonge Lucas de Jonge
John Jorgensen John Jorgensen
Jens B. Jorgensen Jens B. Jorgensen
Fred L. Drake, Jr.
Andreas Jung Andreas Jung
Tattoo Mabonzo K. Tattoo Mabonzo K.
Bob Kahn Bob Kahn
@ -393,6 +393,7 @@ Holger Krekel
Michael Kremer Michael Kremer
Fabian Kreutz Fabian Kreutz
Hannu Krosing Hannu Krosing
Ivan Krstić
Andrew Kuchling Andrew Kuchling
Vladimir Kushnir Vladimir Kushnir
Cameron Laird Cameron Laird

View file

@ -163,6 +163,8 @@ Library
Extension Modules Extension Modules
----------------- -----------------
- Fix expat to not segfault with specially crafted input.
- Issue #4873: Fix resource leaks in error cases of pwd and grp. - Issue #4873: Fix resource leaks in error cases of pwd and grp.
Build Build

View file

@ -1741,7 +1741,7 @@ PREFIX(updatePosition)(const ENCODING *enc,
const char *end, const char *end,
POSITION *pos) POSITION *pos)
{ {
while (ptr != end) { while (ptr < end) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
#define LEAD_CASE(n) \ #define LEAD_CASE(n) \
case BT_LEAD ## n: \ case BT_LEAD ## n: \