fix(core): remove unicode control characters in item description (#15263)

This commit is contained in:
Tony 2024-04-17 02:51:05 +08:00 committed by GitHub
parent 5a566e6d72
commit 0456ca9541
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -48,6 +48,14 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
}
if (item.description) {
// https://stackoverflow.com/questions/2507608/error-input-is-not-proper-utf-8-indicate-encoding-using-phps-simplexml-lo/40552083#40552083
// https://stackoverflow.com/questions/1497885/remove-control-characters-from-php-string/1497928#1497928
// remove unicode control characters
// see #14940 #14943 #15262
item.description = item.description.replaceAll(/[\u0000-\u0009\u000B\u000C\u000E-\u001F\u007F]/g, '');
}
if (typeof item.author === 'string') {
item.author = collapseWhitespace(item.author) || '';
} else if (typeof item.author === 'object' && item.author !== null) {