🚚 Refactor form elemts
This commit is contained in:
@@ -11,3 +11,17 @@ export const asciiHash = (input) => {
|
||||
const shortened = asciiSum.slice(0, 30) + asciiSum.slice(asciiSum.length - 30);
|
||||
return window.btoa(shortened);
|
||||
};
|
||||
|
||||
/* Encode potentially malicious characters from string */
|
||||
export const sanitize = (string) => {
|
||||
const map = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/',
|
||||
};
|
||||
const reg = /[&<>"'/]/ig;
|
||||
return string.replace(reg, (match) => (map[match]));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user