python/python-2.6.2-expat.patch
OBS User autobuild b557378c0d Accepting request 30832 from devel:languages:python:Factory
Copy from devel:languages:python:Factory/python based on submit request 30832 from user matejcik

OBS-URL: https://build.opensuse.org/request/show/30832
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python?expand=0&rev=42
2010-01-29 17:51:47 +00:00

53 lines
1.7 KiB
Diff

Index: Lib/test/test_pyexpat.py
===================================================================
--- Lib/test/test_pyexpat.py.orig
+++ Lib/test/test_pyexpat.py
@@ -559,6 +559,24 @@ class ChardataBufferTest(unittest.TestCa
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,
@@ -569,7 +587,8 @@ def test_main():
HandlerExceptionTest,
PositionTest,
sf1296433Test,
- ChardataBufferTest)
+ ChardataBufferTest,
+ MalformedInputText)
if __name__ == "__main__":
test_main()
Index: Modules/expat/xmltok_impl.c
===================================================================
--- Modules/expat/xmltok_impl.c.orig
+++ Modules/expat/xmltok_impl.c
@@ -1741,7 +1741,7 @@ PREFIX(updatePosition)(const ENCODING *e
const char *end,
POSITION *pos)
{
- while (ptr != end) {
+ while (ptr < end) {
switch (BYTE_TYPE(enc, ptr)) {
#define LEAD_CASE(n) \
case BT_LEAD ## n: \