X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/4bf43ab9d4e6b724836724c1d514760d164df79a..HEAD:/Plugson/www/static/js/jquery.validate.vtoymethods.js?ds=sidebyside diff --git a/Plugson/www/static/js/jquery.validate.vtoymethods.js b/Plugson/www/static/js/jquery.validate.vtoymethods.js index 624c40e..9e640b9 100644 --- a/Plugson/www/static/js/jquery.validate.vtoymethods.js +++ b/Plugson/www/static/js/jquery.validate.vtoymethods.js @@ -1,3 +1,16 @@ +function ventoy_check_file_name_char(path) { + for (var i = 0; i < path.length; i++) { + var cc = path[i]; + if (cc === '/' || cc === '\\' || cc === '*' || cc === '?' || cc === '"' || cc === '<' || cc === '>' || cc === '|') + { + return false; + } + } + + return true; +} + + (function(factory) { if (typeof define === "function" && define.amd) { define(["jquery", "../jquery.validate"], factory); @@ -62,6 +75,14 @@ return true; }, 'Can not contain double quotes'); + + $.validator.addMethod('filenamepart', function(value, element, params) { + if (this.optional(element)) { + return true; + } + + return ventoy_check_file_name_char(value); + }, 'Invalid characters'); $.validator.addMethod('printascii', function(value, element, params) {