sanitizeString fixed. see #689
This commit is contained in:
parent
0a3e697011
commit
2534c499d0
1 changed files with 6 additions and 5 deletions
|
|
@ -482,7 +482,6 @@ function getTagsKeyFromLabel(tag_names, all_tags_list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeString(input) {
|
function sanitizeString(input) {
|
||||||
input = input.toLowerCase();
|
|
||||||
// Define the regex to match valid characters
|
// Define the regex to match valid characters
|
||||||
const validChar = /^[^ ()/{%*<>"]+$/;
|
const validChar = /^[^ ()/{%*<>"]+$/;
|
||||||
// Filter out invalid characters from the string
|
// Filter out invalid characters from the string
|
||||||
|
|
@ -492,14 +491,16 @@ function sanitizeString(input) {
|
||||||
if (cp > 0x7F) {
|
if (cp > 0x7F) {
|
||||||
// Encode non-ASCII characters (e.g. Chinese, emoji) as uXXXX
|
// Encode non-ASCII characters (e.g. Chinese, emoji) as uXXXX
|
||||||
sanitized += 'u' + cp.toString(16);
|
sanitized += 'u' + cp.toString(16);
|
||||||
} else if (validChar.test(char)) {
|
} else {
|
||||||
sanitized += char;
|
if (validChar.test(lower)) {
|
||||||
|
sanitized += lower;
|
||||||
|
}
|
||||||
|
// else: discard blacklisted ASCII chars
|
||||||
}
|
}
|
||||||
// else: discard blacklisted ASCII chars
|
|
||||||
}
|
}
|
||||||
// Truncate to fit the 50-char total key limit:
|
// Truncate to fit the 50-char total key limit:
|
||||||
// $ta- (4) + callID (16) + - (1) + sanitized (max 29) = 50
|
// $ta- (4) + callID (16) + - (1) + sanitized (max 29) = 50
|
||||||
return sanitized.slice(0, 29);
|
return sanitized.toLowerCase().slice(0, 29);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returnType:
|
/* returnType:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue