Skip to content

Commit c18efef

Browse files
committed
victorjonsson#381 Dont escape already escaped values
1 parent d49af49 commit c18efef

34 files changed

+65
-45
lines changed

form-validator/brazil.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/date.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/file.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/html5.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/jquery.form-validator.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/** File generated by Grunt -- do not modify
1818
* JQUERY-FORM-VALIDATOR
1919
*
20-
* @version 2.2.203
20+
* @version 2.2.205
2121
* @website http://formvalidator.net/
2222
* @author Victor Jonsson, http://victorjonsson.se
2323
* @license MIT
@@ -323,7 +323,7 @@
323323
/**
324324
* File declaring all methods if this plugin which is applied to $.fn.
325325
*/
326-
(function($, window) {
326+
(function($, window, undefined) {
327327

328328
'use strict';
329329

@@ -1083,6 +1083,9 @@
10831083

10841084
$.formUtils = $.extend($.formUtils || {}, {
10851085

1086+
tabKey: 9,
1087+
shiftKey: 16,
1088+
10861089
$win: $win,
10871090

10881091
/**

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

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/jsconf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** File generated by Grunt -- do not modify
22
* JQUERY-FORM-VALIDATOR
33
*
4-
* @version 2.2.203
4+
* @version 2.2.205
55
* @website http://formvalidator.net/
66
* @author Victor Jonsson, http://victorjonsson.se
77
* @license MIT

form-validator/lang/cz.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/lang/de.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/lang/dk.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/lang/es.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/lang/fr.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/lang/it.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/lang/nl.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/lang/no.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/lang/pl.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/lang/pt.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/lang/ro.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/lang/ru.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/lang/sv.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/location.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/logic.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/poland.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/sanitize.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/security.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/sweden.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/toggleDisabled.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/uk.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.

formvalidator.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"validation",
88
"validator"
99
],
10-
"version": "2.2.203",
10+
"version": "2.2.205",
1111
"author": {
1212
"name": "Victor Jonsson",
1313
"url": "http://victorjonsson.se",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-form-validator",
33
"description": "With this feature rich jQuery plugin it becomes easy to validate user input while keeping your HTML markup clean from javascript code. Even though this plugin has a wide range of validation functions it's designed to require as little bandwidth as possible. This is achieved by grouping together validation functions in \"modules\", making it possible for the programmer to load only those functions that's needed to validate a particular form.",
4-
"version": "2.2.203",
4+
"version": "2.2.205",
55
"main": "./form-validator/jquery.form-validator.min.js",
66
"keywords": [
77
"form",

src/main/jquery-plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* File declaring all methods if this plugin which is applied to $.fn.
33
*/
4-
(function($, window) {
4+
(function($, window, undefined) {
55

66
'use strict';
77

src/main/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
$.formUtils = $.extend($.formUtils || {}, {
1111

12+
tabKey: 9,
13+
shiftKey: 16,
14+
1215
$win: $win,
1316

1417
/**

src/modules/sanitize.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,31 @@
8888
});
8989
return val;
9090
},
91-
escape : function(val) {
92-
var symbols = {
93-
'<' : '__%AMP%__lt;',
94-
'>' : '__%AMP%__gt;',
95-
'&' : '__%AMP%__amp;',
96-
'\'': '__%AMP%__#8217;',
97-
'"' : '__%AMP%__quot;'
98-
};
99-
$.each(symbols, function(symbol, replacement) {
91+
escape : function(val, $input) {
92+
var isEscaped = $input.valAttr('is-escaped'),
93+
entities = {
94+
'<' : '__%AMP%__lt;',
95+
'>' : '__%AMP%__gt;',
96+
'&' : '__%AMP%__amp;',
97+
'\'': '__%AMP%__#8217;',
98+
'"' : '__%AMP%__quot;'
99+
};
100+
101+
if (isEscaped === 'yes') {
102+
return val;
103+
}
104+
105+
$input.valAttr('is-escaped', 'yes');
106+
$input.one('keyup', function(evt) {
107+
if( evt.keyCode !== $.formUtils.tabKey ) {
108+
$input.valAttr('is-escaped', 'no');
109+
}
110+
});
111+
112+
$.each(entities, function(symbol, replacement) {
100113
val = val.replace(new RegExp(symbol, 'g'), replacement);
101114
});
115+
102116
return val.replace(new RegExp('__\%AMP\%__', 'g'), '&');
103117
}
104118
},

test/qunit.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,11 @@
833833
attr: {
834834
'data-sanitize-strip' : '$, @'
835835
}
836-
}, /* This functionality doesn't work correctly. See issue #381
836+
},
837837
escape: {
838838
val: '<p style="color: pink">hejsan & så\' vidare</p>',
839839
expected: '&lt;p style=&quot;color: pink&quot;&gt;hejsan &amp; så&#8217; vidare&lt;/p&gt;'
840-
}, */
840+
},
841841
basicNumberFormat1: {
842842
val: '-8000.00',
843843
expected: '-8,000.0',

0 commit comments

Comments
 (0)