Ver código fonte

PR447 [oozie] Update the tests with the cleaner escaping of workflow names

Romain Rigaux 9 anos atrás
pai
commit
928c6e41b3

+ 5 - 14
apps/oozie/src/oozie/models2.py

@@ -25,6 +25,7 @@ import uuid
 from datetime import datetime, timedelta
 from dateutil.parser import parse
 from string import Template
+from xml.sax.saxutils import escape
 
 from django.core.urlresolvers import reverse
 from django.db.models import Q
@@ -75,20 +76,10 @@ class Job(object):
 
   @property
   def validated_name(self):
-    xml_entities = {
-            '"': '"',
-            '\'': ''',
-            '&': '&',
-            '<': '&lt;',
-            '>': '&gt;',
-    }
-    good_name = []
-
-    for c in self.name[:40]:
-        c = xml_entities.get(c, c)
-        good_name.append(c)
-
-    return ''.join(good_name)
+    return ''.join(escape(self.name[:40], entities={
+        "'": "&apos;",
+        "\"": "&quot;"
+    }))
 
   def __str__(self):
     return '%s' % force_unicode(self.name)

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
apps/oozie/src/oozie/models2_tests.py


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff