From 8e8a12577625ad0f5ee5a107826f2fcff065bdf3 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Mon, 12 Jan 2015 14:20:41 -0500 Subject: [PATCH] Adjusted Variable parsing had to change variable parsing to a nested variable object but to not accept something like : "jenkins_uri: {{ ansible_ssh_host }}" --- awx/ui/static/js/helpers/Variables.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/awx/ui/static/js/helpers/Variables.js b/awx/ui/static/js/helpers/Variables.js index c2aba884d9..6673b91d05 100644 --- a/awx/ui/static/js/helpers/Variables.js +++ b/awx/ui/static/js/helpers/Variables.js @@ -111,15 +111,18 @@ angular.module('VariablesHelper', ['Utilities']) if(variables.trim() === "" || variables.trim() === "-" || variables.trim() === "--"){ variables = '---'; } - json_data = jsyaml.load(variables); + json_data = jsyaml.safeLoad(variables); if(json_data!==null){ - $.each( json_data, function( key, value ) { - // console.log( key + ": " + value ); - if(value.toString() === "[object Object]"){ - json_data = undefined; - throw 'Failed to parse YAML string. Parser returned ' + key + ' : ' + value + '.'; - } - }); + // $.each( json_data, function( key, value ) { + // if(value.toString() === "[object Object]"){ + // json_data = undefined; + // throw 'Failed to parse YAML string. Parser returned ' + key + ' : ' + value + '.'; + // } + // }); + var tmp = jsyaml.dump(json_data); + if(tmp.indexOf('[object Object]')!==-1){ + throw "Failed to parse YAML string. Parser returned' + key + ' : ' +value + '.' "; + } } } catch(e) { @@ -132,7 +135,7 @@ angular.module('VariablesHelper', ['Utilities']) // Make sure our JSON is actually an object if (typeof json_data !== 'object') { ProcessErrors(null, variables, null, null, { hdr: 'Error!', - msg: 'Failed to parse variables. Attempted to parse ' + parseType + ' Parser did not return an object.' }); + msg: 'Failed to parse variables. Attempted to parse ' + parseType + '. Parser did not return an object.' }); // setTimeout( function() { throw 'Parse error. Failed to parse variables.'; // }, 1000);