Преглед изворни кода

Templating: added validation for allowed characters in variable names, Closes #1106

Torkel Ödegaard пре 11 година
родитељ
комит
e750498696
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      src/app/controllers/templateEditorCtrl.js

+ 5 - 0
src/app/controllers/templateEditorCtrl.js

@@ -45,6 +45,11 @@ function (angular, _) {
         return false;
       }
 
+      if (!$scope.current.name.match(/^\w+$/)) {
+        $scope.appEvent('alert-warning', ['Validation', 'Only word and digit characters are allowed in variable names']);
+        return false;
+      }
+
       var sameName = _.findWhere($scope.variables, { name: $scope.current.name });
       if (sameName && sameName !== $scope.current) {
         $scope.appEvent('alert-warning', ['Validation', 'Variable with the same name already exists']);