From 60b0ee0e6be8166e1ef8999da0f4a7a09b2ed190 Mon Sep 17 00:00:00 2001 From: Martii Date: Wed, 18 Aug 2021 14:30:37 -0600 Subject: [PATCH] Normalize UA to alphanum * Also catch comment UAs * This should catch any further deviations from *useragent* dep Post 95b2db8 #1832 #764 --- libs/modelParser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/modelParser.js b/libs/modelParser.js index 0ae3bf25f..9fc92f70f 100644 --- a/libs/modelParser.js +++ b/libs/modelParser.js @@ -898,7 +898,7 @@ var parseComment = function (aComment) { comment.ua = {}; comment.ua.raw = comment.userAgent; - ua = useragent.parse(comment.userAgent).family.toLowerCase().replace(/\s+/g, '-'); + ua = useragent.parse(comment.userAgent).family.toLowerCase().replace(/[^a-zA-Z0-9]+/g, '-'); if (ua !== 'other') { comment.ua.class = 'fa-lg ua-' + ua; } else if (comment.userAgent) { @@ -1172,7 +1172,7 @@ var parseSession = function (aSession) { oujsOptions.remoteAddressMask = oujsOptions.remoteAddress; oujsOptions.userAgentFamily = useragent - .parse(oujsOptions.userAgent).family.toLowerCase().replace(/[\s\/]+/g, '-'); + .parse(oujsOptions.userAgent).family.toLowerCase().replace(/[^a-zA-Z0-9]+/g, '-'); parseDateProperty(oujsOptions, 'since'); cookie.sameSiteStrict = cookie.sameSite === 'strict';