Forráskód Böngészése

AMBARI-3039: Security wizard configurations should escape special XML chars. (jaimin)

Jaimin Jetly 11 éve
szülő
commit
3bc5effcfa

+ 13 - 0
ambari-web/app/controllers/main/admin/security/add/step4.js

@@ -598,6 +598,7 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
       _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
     }, this);
     if (this.addSecureConfigs()) {
+      this.escapeXMLCharacters(this.get('serviceConfigTags'));
       this.applyConfigurationsToCluster();
     }
   },
@@ -612,6 +613,18 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
     console.log("TRACE: error code status is: " + request.status);
   },
 
+  /*
+    Iterate over keys of all configurations and escape xml characters in their values
+   */
+  escapeXMLCharacters: function(serviceConfigTags) {
+    serviceConfigTags.forEach(function (_serviceConfigTags) {
+      var configs = _serviceConfigTags.configs;
+        for (var key in configs) {
+          configs[key] =  App.config.escapeXMLCharacters(configs[key]);
+        }
+    },this);
+  },
+
   addSecureConfigs: function () {
     try {
       this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {

+ 12 - 0
ambari-web/app/controllers/main/admin/security/disable.js

@@ -286,6 +286,7 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
       _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
     }, this);
     if (this.removeSecureConfigs()) {
+      this.escapeXMLCharacters(this.get('serviceConfigTags'));
       this.applyConfigurationsToCluster();
     }
   },
@@ -355,6 +356,17 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
     }
   },
 
+  /*
+   Iterate over keys of all configurations and escape xml characters in their values
+   */
+  escapeXMLCharacters: function(serviceConfigTags) {
+    serviceConfigTags.forEach(function (_serviceConfigTags) {
+      var configs = _serviceConfigTags.configs;
+      for (var key in configs) {
+        configs[key] =  App.config.escapeXMLCharacters(configs[key]);
+      }
+    },this);
+  },
 
   removeSecureConfigs: function () {
     try {