Skip to content

Commit 6d1f26d

Browse files
committed
Fix ReDoS vulnerabilities reported by Snyk
1 parent 86471ad commit 6d1f26d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/ua-parser.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222

223223
// Presto based
224224
/(opera\smini)\/([\w\.-]+)/i, // Opera Mini
225-
/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
225+
/(opera\s[mobiletab]{3,6}).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
226226
/(opera).+version\/([\w\.]+)/i, // Opera > 9.80
227227
/(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80
228228
], [NAME, VERSION], [
@@ -252,7 +252,7 @@
252252
/(konqueror)\/([\w\.]+)/i // Konqueror
253253
], [[NAME, 'Konqueror'], VERSION], [
254254

255-
/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11
255+
/(trident).+rv[:\s]([\w\.]{1,9}).+like\sgecko/i // IE11
256256
], [[NAME, 'IE'], VERSION], [
257257

258258
/(edge|edgios|edga|edg)\/((\d+)?[\w\.]+)/i // Microsoft Edge
@@ -362,13 +362,13 @@
362362
/fxios\/([\w\.-]+)/i // Firefox for iOS
363363
], [VERSION, [NAME, 'Firefox']], [
364364

365-
/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
365+
/version\/([\w\.]+)\s.*mobile\/\w+\s(safari)/i // Mobile Safari
366366
], [VERSION, [NAME, 'Mobile Safari']], [
367367

368-
/version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
368+
/version\/([\w\.]+)\s.*(mobile\s?safari|safari)/i // Safari & Safari Mobile
369369
], [VERSION, NAME], [
370370

371-
/webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Google Search Appliance on iOS
371+
/webkit.+?(gsa)\/([\w\.]+)\s.*(mobile\s?safari|safari)(\/[\w\.]+)/i // Google Search Appliance on iOS
372372
], [[NAME, 'GSA'], VERSION], [
373373

374374
/webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
@@ -387,7 +387,7 @@
387387

388388
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
389389
/(firefox)\/([\w\.]+)\s[\w\s\-]+\/[\w\.]+$/i, // Other Firefox-based
390-
/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
390+
/(mozilla)\/([\w\.]+)\s.+rv\:.+gecko\/\d+/i, // Mozilla
391391

392392
// Other
393393
/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,
@@ -487,7 +487,7 @@
487487
/(sprint\s(\w+))/i // Sprint Phones
488488
], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [
489489

490-
/(htc)[;_\s-]+([\w\s]+(?=\)|\sbuild)|\w+)/i, // HTC
490+
/(htc)[;_\s-]{1,2}([\w\s]+(?=\)|\sbuild)|\w+)/i, // HTC
491491
/(zte)-(\w*)/i, // ZTE
492492
/(alcatel|geeksphone|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i
493493
// Alcatel/GeeksPhone/Nexian/Panasonic/Sony
@@ -591,13 +591,13 @@
591591
], [MODEL, [VENDOR, 'Google'], [TYPE, MOBILE]], [
592592

593593
/android.+;\s(\w+)\s+build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
594-
/android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, // Xiaomi Hongmi
595-
/android.+(redmi[\s\-_]*(?:note|k)?(?:[\s_]?[\w\s]+))(?:\s+build|\))/i,
594+
/android.+(hm[\s\-_]?note?[\s_]?(?:\d\w)?)\sbuild/i, // Xiaomi Hongmi
595+
/android.+(redmi[\s\-_]?(?:note|k)?(?:[\s_]?[\w\s]+))(?:\sbuild|\))/i,
596596
// Xiaomi Redmi
597-
/android.+(mi[\s\-_]*(?:a\d|one|one[\s_]plus|note lte)?[\s_]?(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i
597+
/android.+(mi[\s\-_]?(?:a\d|one|one[\s_]plus|note lte)?[\s_]?(?:\d?\w?)[\s_]?(?:plus)?)\sbuild/i
598598
// Xiaomi Mi
599599
], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [
600-
/android.+(mi[\s\-_]*(?:pad)(?:[\s_]?[\w\s]+))(?:\s+build|\))/i // Mi Pad tablets
600+
/android.+(mi[\s\-_]?(?:pad)(?:[\s_]?[\w\s]+))(?:\sbuild|\))/i // Mi Pad tablets
601601
],[[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, TABLET]], [
602602
/android.+;\s(m[1-5]\snote)\sbuild/i // Meizu
603603
], [MODEL, [VENDOR, 'Meizu'], [TYPE, MOBILE]], [
@@ -611,7 +611,7 @@
611611
/android.+[;\/]\s*(RCT[\d\w]+)\s+build/i // RCA Tablets
612612
], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
613613

614-
/android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i // Dell Venue Tablets
614+
/android.+[;\/\s](Venue[\d\s]{2,7})\s+build/i // Dell Venue Tablets
615615
], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
616616

617617
/android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i // Verizon Tablet
@@ -669,8 +669,8 @@
669669
/android.+[;\/]\s*TU_(1491)\s+build/i // Rotor Tablets
670670
], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [
671671

672-
/android.+(KS(.+))\s+build/i // Amazon Kindle Tablets
673-
], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
672+
//android.+(KS(.+))\s+build/i // Amazon Kindle Tablets
673+
//], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
674674

675675
/android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i // Gigaset Tablets
676676
], [VENDOR, MODEL, [TYPE, TABLET]], [

0 commit comments

Comments
 (0)