From 252a5944219bb81511236cbde8e90ff67795d3ed Mon Sep 17 00:00:00 2001 From: lubber-de Date: Tue, 4 Dec 2018 17:32:42 +0100 Subject: [PATCH] fix(form,dropdown): Enhanced regexp escaping for jquery .filter and .find to support values containing :,=@. Broke otherwise. Also optimized form field fetching to reduce CPU time --- src/definitions/behaviors/form.js | 19 ++++++++++--------- src/definitions/modules/dropdown.js | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index 4c225dbc78..083ba89cd1 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -514,17 +514,18 @@ $.fn.form = function(parameters) { field: function(identifier) { module.verbose('Finding field with identifier', identifier); identifier = module.escape.string(identifier); - if($field.filter('#' + identifier).length > 0 ) { - return $field.filter('#' + identifier); + var t; + if((t=$field.filter('#' + identifier)).length > 0 ) { + return t; } - else if( $field.filter('[name="' + identifier +'"]').length > 0 ) { - return $field.filter('[name="' + identifier +'"]'); + if((t=$field.filter('[name="' + identifier +'"]')).length > 0 ) { + return t; } - else if( $field.filter('[name="' + identifier +'[]"]').length > 0 ) { - return $field.filter('[name="' + identifier +'[]"]'); + if((t=$field.filter('[name="' + identifier +'[]"]')).length > 0 ) { + return t; } - else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').length > 0 ) { - return $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]'); + if((t=$field.filter('[data-' + metadata.validate + '="'+ identifier +'"]')).length > 0 ) { + return t; } return $(''); }, @@ -1239,7 +1240,7 @@ $.fn.form.settings = { bracket : /\[(.*)\]/i, decimal : /^\d+\.?\d*$/, email : /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i, - escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, + escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|:,=@]/g, flags : /^\/(.*)\/(.*)?/, integer : /^\-?\d+$/, number : /^\-?\d*(\.\d+)?$/, diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index aae2fbe82a..432f136a24 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -3874,7 +3874,7 @@ $.fn.dropdown.settings = { }, regExp : { - escape : /[-[\]{}()*+?.,\\^$|#\s]/g, + escape : /[-[\]{}()*+?.,\\^$|#\s:=@]/g, quote : /"/g },