mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
cross-site scripting - sanitize only value whose type is string.
This commit is contained in:
parent
272d419d3a
commit
4e9b1239ce
@ -1250,7 +1250,7 @@ function noNull(val) {
|
||||
// Prevent cross-site-script(XSS) attack.
|
||||
// used right before adding user input to the DOM tree. e.g. DOM_element.html(sanitizeXSS(user_input));
|
||||
function sanitizeXSS(val) {
|
||||
if(val == null)
|
||||
if(val == null || typeof(val) != "string")
|
||||
return val;
|
||||
val = val.replace(/</g, "<"); //replace < whose unicode is \u003c
|
||||
val = val.replace(/>/g, ">"); //replace > whose unicode is \u003e
|
||||
|
||||
@ -626,7 +626,7 @@ function noNull(val) {
|
||||
// Prevent cross-site-script(XSS) attack.
|
||||
// used right before adding user input to the DOM tree. e.g. DOM_element.html(sanitizeXSS(user_input));
|
||||
function sanitizeXSS(val) {
|
||||
if(val == null)
|
||||
if(val == null || typeof(val) != "string")
|
||||
return val;
|
||||
val = val.replace(/</g, "<"); //replace < whose unicode is \u003c
|
||||
val = val.replace(/>/g, ">"); //replace > whose unicode is \u003e
|
||||
|
||||
@ -102,7 +102,7 @@ function trim(val) {
|
||||
// Prevent cross-site-script(XSS) attack.
|
||||
// used right before adding user input to the DOM tree. e.g. DOM_element.html(sanitizeXSS(user_input));
|
||||
function sanitizeXSS(val) {
|
||||
if(val == null)
|
||||
if(val == null || typeof(val) != "string")
|
||||
return val;
|
||||
val = val.replace(/</g, "<"); //replace < whose unicode is \u003c
|
||||
val = val.replace(/>/g, ">"); //replace > whose unicode is \u003e
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user