瀏覽代碼

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

Romain Rigaux 9 年之前
父節點
當前提交
928c6e41b3
共有 2 個文件被更改,包括 6 次插入15 次删除
  1. 5 14
      apps/oozie/src/oozie/models2.py
  2. 1 1
      apps/oozie/src/oozie/models2_tests.py

+ 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)

File diff suppressed because it is too large
+ 1 - 1
apps/oozie/src/oozie/models2_tests.py


Some files were not shown because too many files changed in this diff