Skip to content

Commit 1e1d6b9

Browse files
author
T_S_V
committed
Fixed T2679 - Single Quatation character issue -- escaping values (if strings)
1 parent 23a7711 commit 1e1d6b9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/icheck.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
function escValue(val) {
2+
if (typeof val === 'string') {
3+
return (val || "").replace(/(?!^)(['])(?!$)/g, "\\$1");
4+
}
5+
return val;
6+
}
7+
18
function init(Survey, $) {
29
$ = $ || window.$;
310
var widget = {
@@ -35,7 +42,7 @@ function init(Survey, $) {
3542
values = [values];
3643
}
3744
values.forEach(function(value) {
38-
$el.find("input[value='" + value + "']").iCheck("check");
45+
$el.find("input[value='" + escValue(value) + "']").iCheck("check");
3946
});
4047
} else {
4148
question.generatedVisibleRows.forEach(function(row, index, rows) {
@@ -45,7 +52,7 @@ function init(Survey, $) {
4552
"input[name='" +
4653
row.fullName +
4754
"'][value='" +
48-
row.value +
55+
escValue(row.value) +
4956
"']"
5057
)
5158
.iCheck("check");

0 commit comments

Comments
 (0)