Skip to content
Snippets Groups Projects
Commit 75e2d032 authored by Vincent Nivoliers's avatar Vincent Nivoliers
Browse files

basic prevention of js injection through inputs

parent 352303ff
No related branches found
No related tags found
No related merge requests found
......@@ -453,8 +453,8 @@ script {
}
.pgm-recv .list-group-item {
border : 1px solid #ddd !important ;
border-radius : 5px !important ;
border : 1px solid #ddd ;
border-radius : 5px ;
vertical-align : middle ;
padding : 3px;
}
......
......@@ -31,7 +31,7 @@ function block_compile(el) {
function get_integer(str, error_target) {
var i = parseInt(str) ;
if(isNaN(i)) {
if(!str.match(/^\d+$/) || isNaN(i)) {
return pgm_selector_error(
error_target,
"la valeur fournie n\'est pas un entier : " + str
......@@ -55,7 +55,7 @@ function get_boolean(data, error_target) {
}
function get_str(data, error_target) {
var str = '' + data ;
var str = typeof data === 'string' ? data : '' + data ;
if(str.match(/^[\w\u00C0-\u02B8\-]+$/)) {
return str ;
} else {
......@@ -90,7 +90,8 @@ function receiver_compile(el) {
//compile child
var rec_compile = "" ;
if(target.className.match(/field/)) {
rec_compile = '"' + target.children[0].value + '"' ;
var err_target = selector_path_to_root(target.children[0]) ;
rec_compile = '"' + get_str(target.children[0].value, err_target) + '"' ;
}
else {
rec_compile = cmd_compile(target) ;
......@@ -102,7 +103,7 @@ function receiver_compile(el) {
} else if (type === 'bool') {
return 'get_boolean(' + rec_compile + ',' + err_target + ')' ;
} else if (type === 'str') {
return 'get_str(' + rec_compile + ',' + err_target + ')' ;
return rec_compile ;
} else if (type === 'direction') {
return 'check_direction(' + rec_compile + ',' + err_target + ')'
} else if (type === 'color') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment