diff options
author | Georg Sauthoff <mail@georg.so> | 2017-02-10 15:29:34 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-06-20 05:38:41 -0400 |
commit | d0f59054d0c4b2291a4e0e94ec00537f98a4ab50 (patch) | |
tree | 9abf7a54d07304e5c4c41b42fa7d3d0804290d38 /django/utils/xmlutils.py | |
parent | 335a8d7895a0d73df3d41fac750ff8f412a989b2 (diff) | |
download | django-d0f59054d0c4b2291a4e0e94ec00537f98a4ab50.tar.gz |
Fixed #28324 -- Made feedgenerators write feeds with deterministically ordered attributes.
Diffstat (limited to 'django/utils/xmlutils.py')
-rw-r--r-- | django/utils/xmlutils.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/django/utils/xmlutils.py b/django/utils/xmlutils.py index f1edfb2ac9..6b62a1fe74 100644 --- a/django/utils/xmlutils.py +++ b/django/utils/xmlutils.py @@ -3,6 +3,7 @@ Utilities for XML generation/parsing. """ import re +from collections import OrderedDict from xml.sax.saxutils import XMLGenerator @@ -26,3 +27,8 @@ class SimplerXMLGenerator(XMLGenerator): # See http://www.w3.org/International/questions/qa-controls raise UnserializableContentError("Control characters are not supported in XML 1.0") XMLGenerator.characters(self, content) + + def startElement(self, name, attrs): + # Sort attrs for a deterministic output. + sorted_attrs = OrderedDict(sorted(attrs.items())) if attrs else attrs + super().startElement(name, sorted_attrs) |