Просмотр исходного кода

Remove frontend validation on ingredients.

Lee Morgan 5 лет назад
Родитель
Сommit
b1b9653997
2 измененных файлов с 0 добавлено и 58 удалено
  1. 0 29
      views/dashboardPage/bundle.js
  2. 0 29
      views/dashboardPage/js/classes/Ingredient.js

+ 0 - 29
views/dashboardPage/bundle.js

@@ -1,15 +1,6 @@
 (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
 class Ingredient{
     constructor(id, name, category, unitType, unit, parent, specialUnit = undefined, unitSize = undefined){
-        if(!this.isSanitaryString(name)){
-            controller.createBanner("NAME CONTAINS ILLEGAL CHARCTERS", "error");
-            return false;
-        }
-        if(!this.isSanitaryString(category)){
-            controller.createBanner("CATEGORY CONTAINS ILLEGAL CHARACTERS", "error");
-            return false;
-        }
-
         this._id = id;
         this._name = name;
         this._category = category;
@@ -31,10 +22,6 @@ class Ingredient{
     }
 
     set name(name){
-        if(!this.isSanitaryString(name)){
-            return false;
-        }
-
         this._name = name;
     }
 
@@ -43,10 +30,6 @@ class Ingredient{
     }
 
     set category(category){
-        if(!this.isSanitaryString(category)){
-            return false;
-        }
-
         this._category = category;
     }
 
@@ -113,18 +96,6 @@ class Ingredient{
 
         return `${this._name} (${this._unit.toUpperCase()})`;
     }
-
-    isSanitaryString(str){
-        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
-
-        for(let i = 0; i < disallowed.length; i++){
-            if(str.includes(disallowed[i])){
-                return false;
-            }
-        }
-
-        return true;
-    }
 }
 
 module.exports = Ingredient;

+ 0 - 29
views/dashboardPage/js/classes/Ingredient.js

@@ -1,14 +1,5 @@
 class Ingredient{
     constructor(id, name, category, unitType, unit, parent, specialUnit = undefined, unitSize = undefined){
-        if(!this.isSanitaryString(name)){
-            controller.createBanner("NAME CONTAINS ILLEGAL CHARCTERS", "error");
-            return false;
-        }
-        if(!this.isSanitaryString(category)){
-            controller.createBanner("CATEGORY CONTAINS ILLEGAL CHARACTERS", "error");
-            return false;
-        }
-
         this._id = id;
         this._name = name;
         this._category = category;
@@ -30,10 +21,6 @@ class Ingredient{
     }
 
     set name(name){
-        if(!this.isSanitaryString(name)){
-            return false;
-        }
-
         this._name = name;
     }
 
@@ -42,10 +29,6 @@ class Ingredient{
     }
 
     set category(category){
-        if(!this.isSanitaryString(category)){
-            return false;
-        }
-
         this._category = category;
     }
 
@@ -112,18 +95,6 @@ class Ingredient{
 
         return `${this._name} (${this._unit.toUpperCase()})`;
     }
-
-    isSanitaryString(str){
-        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
-
-        for(let i = 0; i < disallowed.length; i++){
-            if(str.includes(disallowed[i])){
-                return false;
-            }
-        }
-
-        return true;
-    }
 }
 
 module.exports = Ingredient;