Skip to content

Commit 73c8b60

Browse files
committed
fixed bugs in sanitation module
1 parent 0c25635 commit 73c8b60

20 files changed

+54
-28
lines changed

form-validator/date.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#location-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.2.48
13+
* @version 2.2.51
1414
*/
1515
(function($) {
1616

form-validator/file.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#file-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.2.48
13+
* @version 2.2.51
1414
*/
1515
(function($, window) {
1616

form-validator/html5.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @website http://formvalidator.net/
1919
* @license Dual licensed under the MIT or GPL Version 2 licenses
20-
* @version 2.2.48
20+
* @version 2.2.51
2121
*/
2222
(function($, window) {
2323

form-validator/jquery.form-validator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @website http://formvalidator.net/
77
* @license Dual licensed under the MIT or GPL Version 2 licenses
8-
* @version 2.2.48
8+
* @version 2.2.51
99
*/
1010
(function ($) {
1111

form-validator/jquery.form-validator.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/jsconf.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @website http://formvalidator.net/#location-validators
99
* @license Dual licensed under the MIT or GPL Version 2 licenses
10-
* @version 2.2.48
10+
* @version 2.2.51
1111
*/
1212
(function($) {
1313

form-validator/lang/de.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @website http://formvalidator.net/
88
* @license Dual licensed under the MIT or GPL Version 2 licenses
9-
* @version 2.2.48
9+
* @version 2.2.51
1010
*/
1111
(function($, window) {
1212

form-validator/lang/es.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @website http://formvalidator.net/
88
* @license Dual licensed under the MIT or GPL Version 2 licenses
9-
* @version 2.2.48
9+
* @version 2.2.51
1010
*/
1111
(function($, window) {
1212

form-validator/lang/fr.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @website http://formvalidator.net/
88
* @license Dual licensed under the MIT or GPL Version 2 licenses
9-
* @version 2.2.48
9+
* @version 2.2.51
1010
*/
1111
(function($, window) {
1212

form-validator/lang/pt.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @website http://formvalidator.net/
88
* @license Dual licensed under the MIT or GPL Version 2 licenses
9-
* @version 2.2.48
9+
* @version 2.2.51
1010
*/
1111
(function($, window) {
1212

form-validator/lang/sv.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @website http://formvalidator.net/
88
* @license Dual licensed under the MIT or GPL Version 2 licenses
9-
* @version 2.2.48
9+
* @version 2.2.51
1010
*/
1111
(function($, window) {
1212

form-validator/location.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#location-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.2.48
13+
* @version 2.2.51
1414
*/
1515
(function($) {
1616

form-validator/qunit.html

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@
682682
test('Sanitation', function() {
683683
clearForm();
684684

685-
var data = {
685+
var sanitationTests = {
686686
trim : {
687687
val : ' apa ',
688688
expected : 'apa'
@@ -727,25 +727,41 @@
727727
'data-sanitize-insert-left' : 'left...'
728728
}
729729
},
730+
insertRightOmitted : {
731+
val : ' apa $',
732+
expected: ' apa $',
733+
sanitize : 'insertRight',
734+
attr : {
735+
'data-sanitize-insert-right' : ' $'
736+
}
737+
},
738+
insertLeftOmitted : {
739+
val : '$ apa $',
740+
expected: '$ apa $',
741+
sanitize : 'insertRight',
742+
attr : {
743+
'data-sanitize-insert-left' : '$ '
744+
}
745+
},
730746
'trim insertRight' : {
731747
val : ' apa ',
732-
expected: 'aparight...',
748+
expected: 'apa right...',
733749
attr : {
734-
'data-sanitize-insert-right' : 'right...'
750+
'data-sanitize-insert-right' : ' right...'
735751
}
736752
},
737753
escape : {
738754
val : '<p style="color: pink">hejsan & så\' vidare</p>',
739755
expected: '&lt;p style=&quot;color: pink&quot;&gt;hejsan &amp; så&#8217; vidare&lt;/p&gt;' }
740756
};
741757

742-
$.each(data, function(sanitation, data) {
758+
$.each(sanitationTests, function(sanitation, data) {
743759
var $input = input('hejsan', {'':''}, {name:'test'});
744-
$input.attr('data-sanitize', sanitation);
760+
$input.attr('data-sanitize', data.sanitize || sanitation);
745761
$.each(data.attr || {}, function(attrName, attrVal) {
746762
$input.attr(attrName, attrVal);
747763
});
748-
$.formUtils.setupSanitation($form, $.formUtils.defaultConfig());
764+
$.formUtils.setupSanitation({}, $form, $.formUtils.defaultConfig());
749765
$input.val(data.val);
750766
$input.trigger('blur');
751767
equal(

form-validator/sanitize.dev.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @website http://formvalidator.net/
2424
* @license Dual licensed under the MIT or GPL Version 2 licenses
25-
* @version 2.2.48
25+
* @version 2.2.51
2626
*/
2727
(function($, window) {
2828

@@ -64,15 +64,23 @@
6464
});
6565
return words.join(' ');
6666
},
67+
insert : function(val, $input, pos) {
68+
var extra = ($input.attr('data-sanitize-insert-'+pos) || '').replace(/\[SPACE\]/g, ' ');
69+
if( (pos == 'left' && val.indexOf(extra) == 0) ||
70+
(pos == 'right' && val.substring(val.length - extra.length) == extra)) {
71+
return val;
72+
}
73+
return (pos == 'left' ? extra:'') + val + (pos == 'right' ? extra : '');
74+
},
6775
insertRight : function(val, $input) {
68-
return val + ($input.attr('data-sanitize-insert-right') || '').replace(/\[SPACE\]/g, ' ');
76+
return this.insert(val, $input, 'right');
6977
},
7078
insertLeft : function(val, $input) {
71-
return ($input.attr('data-sanitize-insert-left') || '').replace(/\[SPACE\]/g, ' ') + val;
79+
return this.insert(val, $input, 'left');
7280
},
7381
numberFormat : function(val, $input, config) {
7482
if( 'numeral' in window ) {
75-
val = numeral(val).format( $input.attr('data-sanitation-format') );
83+
val = numeral(val).format( $input.attr('data-number-format') );
7684
} else {
7785
throw new Error('Using sanitation function "numberFormat" requires that you include numeraljs (http://http://numeraljs.com/)');
7886
}
@@ -97,6 +105,8 @@
97105
if( !$forms ) {
98106
$forms = $('form');
99107
}
108+
if( !$forms.each )
109+
$forms = $($forms);
100110

101111
var execSanitationCommands = function() {
102112
var $input = $(this),

form-validator/sanitize.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/security.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* - cvv
1414
*
1515
* @website http://formvalidator.net/#security-validators
16-
* @version 2.2.48
16+
* @version 2.2.51
1717
*/
1818
(function($, window) {
1919

form-validator/sweden.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @website http://formvalidator.net/#swedish-validators
1515
* @license Dual licensed under the MIT or GPL Version 2 licenses
16-
* @version 2.2.48
16+
* @version 2.2.51
1717
*/
1818
(function($, window) {
1919

form-validator/theme-default.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/toggleDisabled.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @website http://formvalidator.net/
1010
* @license Dual licensed under the MIT or GPL Version 2 licenses
11-
* @version 2.2.48
11+
* @version 2.2.51
1212
*/
1313
(function($, window, undefined) {
1414

form-validator/uk.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @website http://formvalidator.net/#uk-validators
1111
* @license Dual licensed under the MIT or GPL Version 2 licenses
12-
* @version 2.2.48
12+
* @version 2.2.51
1313
*/
1414
$.formUtils.addValidator({
1515
name : 'ukvatnumber',

0 commit comments

Comments
 (0)