Skip to content

Commit

Permalink
Normalize UA to alphanum
Browse files Browse the repository at this point in the history
* Also catch comment UAs
* This should catch any further deviations from *useragent* dep

Post 95b2db8 #1832 #764
  • Loading branch information
Martii committed Aug 18, 2021
1 parent 16b685b commit 60b0ee0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/modelParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 60b0ee0

Please sign in to comment.