[Python-checkins] r74436 - in python/branches/release31-maint: Lib/test/test_pyexpat.py Misc/NEWS Modules/expat/xmltok_impl.c

brett.cannon python-checkins at python.org
Thu Aug 13 21:59:04 CEST 2009


Author: brett.cannon
Date: Thu Aug 13 21:59:04 2009
New Revision: 74436
Log:
Backport of r74435. Not merged/blocked w/ svnmerge.py as the tool is erroring out on me.
Modified:
 python/branches/release31-maint/Lib/test/test_pyexpat.py
 python/branches/release31-maint/Misc/NEWS
 python/branches/release31-maint/Modules/expat/xmltok_impl.c
Modified: python/branches/release31-maint/Lib/test/test_pyexpat.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_pyexpat.py	(original)
+++ python/branches/release31-maint/Lib/test/test_pyexpat.py	Thu Aug 13 21:59:04 2009
@@ -510,6 +510,24 @@
 parser.Parse(xml2, 1)
 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():
 run_unittest(SetAttributeTest,
@@ -520,7 +538,8 @@
 HandlerExceptionTest,
 PositionTest,
 sf1296433Test,
- ChardataBufferTest)
+ ChardataBufferTest,
+ MalformedInputText)
 
 if __name__ == "__main__":
 test_main()
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Thu Aug 13 21:59:04 2009
@@ -105,6 +105,8 @@
 Extension Modules
 -----------------
 
+- Fix a segfault in expat.
+
 - Issue #4509: array.array objects are no longer modified after an operation
 failing due to the resize restriction in-place when the object has exported
 buffers.
Modified: python/branches/release31-maint/Modules/expat/xmltok_impl.c
==============================================================================
--- python/branches/release31-maint/Modules/expat/xmltok_impl.c	(original)
+++ python/branches/release31-maint/Modules/expat/xmltok_impl.c	Thu Aug 13 21:59:04 2009
@@ -1741,7 +1741,7 @@
 const char *end,
 POSITION *pos)
 {
- while (ptr != end) {
+ while (ptr < end) {
 switch (BYTE_TYPE(enc, ptr)) {
 #define LEAD_CASE(n) \
 case BT_LEAD ## n: \


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /