aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
authorTom Christie2013-02-22 11:49:57 -0800
committerTom Christie2013-02-22 11:49:57 -0800
commitcf6c95de0112eb7d1c524849e907b586513cdf63 (patch)
treeafb8c1b3fb18fba9af370e7afffd7458d730d7c3 /rest_framework/compat.py
parenta39de47cc7e6861a1d06b8ab1893f7358cf281f9 (diff)
parent78da724964019e33bfa5d9f05db2806d85816c2d (diff)
downloaddjango-rest-framework-cf6c95de0112eb7d1c524849e907b586513cdf63.tar.bz2
Merge pull request #673 from tomchristie/defusedxml
XML Security fixes
Diffstat (limited to 'rest_framework/compat.py')
-rw-r--r--rest_framework/compat.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py
index 3fd865f8..07fdddce 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -421,17 +421,8 @@ except ImportError:
yaml = None
-# xml.etree.parse only throws ParseError for python >= 2.7
+# XML is optional
try:
- from xml.etree import ParseError as ETParseError
-except ImportError: # python < 2.7
- ETParseError = None
-
-
-# XMLParser only takes an encoding arg from >= 2.7
-def ET_XMLParser(encoding=None):
- from xml.etree import ElementTree as ET
- try:
- return ET.XMLParser(encoding=encoding)
- except TypeError:
- return ET.XMLParser()
+ import defusedxml.ElementTree as etree
+except ImportError:
+ etree = None