Browse code

Don't crash when a proxy returns an invalid XML error document

Give us a chance to see it, and maybe continue.

Matt Domsch authored on 2015/02/03 22:06:23
Showing 1 changed files
... ...
@@ -98,11 +98,14 @@ class S3Error (S3Exception):
98 98
         error_node = tree
99 99
         if not error_node.tag == "Error":
100 100
             error_node = tree.find(".//Error")
101
-        for child in error_node.getchildren():
102
-            if child.text != "":
103
-                debug("ErrorXML: " + child.tag + ": " + repr(child.text))
104
-                info[child.tag] = child.text
105
-
101
+            if error_node is not None:
102
+                for child in error_node.getchildren():
103
+                    if child.text != "":
104
+                        debug("ErrorXML: " + child.tag + ": " + repr(child.text))
105
+                        info[child.tag] = child.text
106
+            else:
107
+                warning("Malformed error XML returned from remote server.  Use --debug to see it.")
108
+                debug("ErrorXML: " + repr(tree))
106 109
         return info
107 110
 
108 111