mirror of https://github.com/apache/cloudstack.git
Add helper function to sanitize user input strings
For any strings that require sanitization (i.e., strip HTML/JavaScript), wrap the string around cloudStack.sanitize, or _s for short. This currently will remove embedded HTML tags, which are the main security issues present. Example: var str = '<script>Hello</script>My String'; _s(str) = '<script>Hello</script>My String'
This commit is contained in:
parent
31eef1d183
commit
2e1726cb5f
|
|
@ -54,4 +54,18 @@
|
|||
|
||||
return localized ? localized : str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sanitize user input -- shortcut _s
|
||||
*
|
||||
* Strip unwanted characters from user-based input
|
||||
*/
|
||||
cloudStack.sanitize = window._s = function(str) {
|
||||
var sanitized = str
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">");
|
||||
|
||||
return sanitized;
|
||||
};
|
||||
})(jQuery, cloudStack);
|
||||
|
|
|
|||
Loading…
Reference in New Issue