]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
- Patch #1309009, Fix segfault in pyexpat when the XML document is in latin_1,
authorNeal Norwitz <nnorwitz@gmail.com>
Fri, 30 Sep 2005 04:58:23 +0000 (04:58 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Fri, 30 Sep 2005 04:58:23 +0000 (04:58 +0000)
  but Python incorrectly assumes it is in UTF-8 format

Lib/test/test_minidom.py
Misc/ACKS
Misc/NEWS
Modules/pyexpat.c

index 3154fbf3e629dd886eeeb8118fe8c710f78ad278..8b4c71523c155ec53a698353d0fb1bd0259d64f7 100644 (file)
@@ -889,6 +889,15 @@ def testEncodings():
             and doc.toxml('utf-8') == '<?xml version="1.0" encoding="utf-8"?><foo>\xe2\x82\xac</foo>'
             and doc.toxml('iso-8859-15') == '<?xml version="1.0" encoding="iso-8859-15"?><foo>\xa4</foo>',
             "testEncodings - encoding EURO SIGN")
+
+    # Verify that character decoding errors throw exceptions instead of crashing
+    try:
+        doc = parseString('<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
+    except UnicodeDecodeError:
+        pass
+    else:
+        print 'parsing with bad encoding should raise a UnicodeDecodeError'
+
     doc.unlink()
 
 class UserDataHandler:
index c599172bdf577d2d6b977cbed85345db36927ca8..0fdb79f4fe6e458d644f5b0bb0f7d67ca210f3a9 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -303,6 +303,7 @@ Flemming Kj
 Jiba
 Orjan Johansen
 Simon Johnston
+Evan Jones
 Richard Jones
 Irmen de Jong
 Lucas de Jonge
index c2b32d822f8fcc710a727abc680daeff3ef60b33..47c0ea49fd75982487e9a3727743ad39f87f185e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -4,7 +4,7 @@ Python News
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
-What's New in Python 2.4.3a0?
+What's New in Python 2.4.3c1?
 =============================
 
 *Release date: XX-XX-200X*
@@ -12,6 +12,9 @@ What's New in Python 2.4.3a0?
 Extension Modules
 -----------------
 
+- Patch #1309009, Fix segfault in pyexpat when the XML document is in latin_1,
+  but Python incorrectly assumes it is in UTF-8 format
+
 - Fix parse errors in the readline module when compiling without threads.
 
 Library
index e6c14f8a2db44d58cb5362ddf3da785c070e5747..438f7609cb2249fcc62b72bcd75abfe1b18090b3 100644 (file)
@@ -417,6 +417,9 @@ string_intern(xmlparseobject *self, const char* str)
 {
     PyObject *result = STRING_CONV_FUNC(str);
     PyObject *value;
+    /* result can be NULL if the unicode conversion failed. */
+    if (!result)
+       return result;
     if (!self->intern)
        return result;
     value = PyDict_GetItem(self->intern, result);
@@ -572,7 +575,9 @@ my_StartElementHandler(void *userData,
                 Py_DECREF(v);
             }
         }
-       args = Py_BuildValue("(NN)", string_intern(self, name), container);
+        args = string_intern(self, name);
+        if (args != NULL)
+            args = Py_BuildValue("(NN)", args, container);
         if (args == NULL) {
             Py_DECREF(container);
             return;