correctly fixing tags IDs. see #689
This commit is contained in:
parent
e788f305a0
commit
910f55dc19
1 changed files with 10 additions and 5 deletions
|
|
@ -484,17 +484,22 @@ function getTagsKeyFromLabel(tag_names, all_tags_list) {
|
||||||
function sanitizeString(input) {
|
function sanitizeString(input) {
|
||||||
input = input.toLowerCase();
|
input = input.toLowerCase();
|
||||||
// Define the regex to match valid characters
|
// Define the regex to match valid characters
|
||||||
const regex = /^[^ ()/{%*<>"]+$/;
|
const validChar = /^[^ ()/{%*<>"]+$/;
|
||||||
// Filter out invalid characters from the string
|
// Filter out invalid characters from the string
|
||||||
let sanitized = '';
|
let sanitized = '';
|
||||||
for (const char of input) {
|
for (const char of input) {
|
||||||
// Check if the character is valid according to the regex
|
const cp = char.codePointAt(0);
|
||||||
if (regex.test(char)) {
|
if (cp > 0x7F) {
|
||||||
|
// Encode non-ASCII characters (e.g. Chinese, emoji) as uXXXX
|
||||||
|
sanitized += 'u' + cp.toString(16);
|
||||||
|
} else if (validChar.test(char)) {
|
||||||
sanitized += char;
|
sanitized += char;
|
||||||
}
|
}
|
||||||
|
// else: discard blacklisted ASCII chars
|
||||||
}
|
}
|
||||||
|
// Truncate to fit the 50-char total key limit:
|
||||||
return sanitized;
|
// $ta- (4) + callID (16) + - (1) + sanitized (max 29) = 50
|
||||||
|
return sanitized.slice(0, 29);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returnType:
|
/* returnType:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue