Browse Source

AMBARI-3009. Trim and/or validate config parameter values to prevent failures due to extra spaces. (Andrii Babiichuk via yusaku)

Yusaku Sako 11 years ago
parent
commit
3633b1e0a3

+ 1 - 0
ambari-web/app/controllers/main/service/info/configs.js

@@ -1004,6 +1004,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     var serviceConfigProperties = configs.filterProperty('id', 'site property');
     serviceConfigProperties.forEach(function(_config){
       if(typeof _config.get('value') === "boolean") _config.set('value', _config.value.toString());
+      _config.set('value', App.config.trimProperty(_config),true);
     });
     var storedConfigs = serviceConfigProperties.filterProperty('value');
     var allUiConfigs = this.loadUiSideConfigs(this.get('configMapping').all());

+ 2 - 2
ambari-web/app/controllers/wizard/step8_controller.js

@@ -78,7 +78,7 @@ App.WizardStep8Controller = Em.Controller.extend({
       this.set('securityEnabled', App.router.get('mainAdminSecurityController').getUpdatedSecurityStatus());
     }
     this.clearStep();
-    this.formatDirectories();
+    this.formatProperties();
     this.loadGlobals();
     this.loadConfigs();
     this.loadClusterInfo();
@@ -89,7 +89,7 @@ App.WizardStep8Controller = Em.Controller.extend({
   /**
    * replace whitespace character with coma between directories
    */
-  formatDirectories: function(){
+  formatProperties: function(){
     this.get('content.serviceConfigProperties').forEach(function(_configProperty){
         _configProperty.value = App.config.trimProperty(_configProperty,false);
     });

+ 3 - 4
ambari-web/app/utils/config.js

@@ -979,15 +979,14 @@ App.config = Em.Object.create({
       case 'host':
         rez = value.trim();
         break;
+      case 'password':
+        break;
       case 'advanced':
         if(name == 'hive_jdbc_connection_url' || name == 'oozie_jdbc_connection_url') {
           rez = value.trim();
         }
-        break;
-      case 'password':
-        break;
       default:
-        rez = (value instanceof String) ? value.replace(/(\s+$)/g, '') : value;
+        rez = (typeof value == 'string') ? value.replace(/(\s+$)/g, '') : value;
     }
     return ((rez == '') || (rez == undefined)) ? value : rez;
   }