Browse Source

PR447 [oozie] Fix non-English workflow name mangling problem

https://github.com/cloudera/hue/pull/447
Wang, Xiaozhe 9 years ago
parent
commit
50bec63e6d
1 changed files with 9 additions and 7 deletions
  1. 9 7
      apps/oozie/src/oozie/models2.py

+ 9 - 7
apps/oozie/src/oozie/models2.py

@@ -75,16 +75,18 @@ class Job(object):
 
   @property
   def validated_name(self):
+    xml_entities = {
+            '"': '"',
+            '\'': ''',
+            '&': '&',
+            '<': '&lt;',
+            '>': '&gt;',
+    }
     good_name = []
 
     for c in self.name[:40]:
-      if not good_name:
-        if not re.match('[a-zA-Z_\{\$\}]', c):
-          c = '_'
-      else:
-        if not re.match('[\-_a-zA-Z0-9\{\$\}]', c):
-          c = '_'
-      good_name.append(c)
+        c = xml_entities.get(c, c)
+        good_name.append(c)
 
     return ''.join(good_name)