[mirotalk] - fix decodeURIComponent

This commit is contained in:
Miroslav Pejic
2025-03-09 10:54:12 +01:00
parent bfdc44d4a7
commit d2044e844f
6 changed files with 16 additions and 8 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ dependencies: {
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.4.83
* @version 1.4.84
*
*/
+10 -2
View File
@@ -71,11 +71,19 @@ function needsDecoding(str) {
return urlEncodedPattern.test(str);
}
// Recursively sanitize data based on its type
function safeDecodeURIComponent(str) {
try {
return decodeURIComponent(str);
} catch (e) {
log.error('Malformed URI component detected:', str);
return str; // Return original string if decoding fails
}
}
function sanitizeData(data) {
if (typeof data === 'string') {
// Decode HTML entities and URL encoded content
const decodedData = needsDecoding(data) ? he.decode(decodeURIComponent(data)) : he.decode(data);
const decodedData = needsDecoding(data) ? he.decode(safeDecodeURIComponent(data)) : he.decode(data);
return purify.sanitize(decodedData);
}