Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

useragent

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

useragent - npm Package Compare versions

Comparing version 2.1.11 to 2.1.12

30

index.js

@@ -409,2 +409,30 @@ 'use strict';

/**
* Check if the userAgent is something we want to parse with regexp's.
*
* @param {String} userAgent The userAgent.
* @returns {Boolean}
*/
function isSafe(userAgent) {
var consecutive = 0
, code = 0;
for (var i = 0; i < userAgent.length; i++) {
code = userAgent.charCodeAt(i);
// numbers between 0 and 9
if (code >= 48 && code <= 57) {
consecutive++;
} else {
consecutive = 0;
}
if (consecutive >= 100) {
return false;
}
}
return true
}
/**
* Parses the user agent string with the generated parsers from the

@@ -419,3 +447,3 @@ * ua-parser project on google code.

exports.parse = function parse(userAgent, jsAgent) {
if (!userAgent) return new Agent();
if (!userAgent || !isSafe(userAgent)) return new Agent();

@@ -422,0 +450,0 @@ var length = agentparserslength

24

lib/update.js

@@ -8,3 +8,4 @@ 'use strict';

, fs = require('fs')
, vm = require('vm');
, vm = require('vm')
, tmp = require('tmp');

@@ -41,9 +42,18 @@ /**

if (source && !err) {
fs.writeFile(exports.output, source, function idk(err) {
if (err) {
console.error('Failed to save the generated file due to reasons', err);
}
if (!source || err) return;
//
// Save to a tmp file to avoid potential concurrency issues.
//
tmp.file(function (err, tempFilePath) {
if (err) return;
fs.writeFile(tempFilePath, source, function idk(err) {
if (err) return
fs.rename(tempFilePath, exports.output, function(err) {
});
});
}
});
});

@@ -50,0 +60,0 @@ });

{
"name": "useragent",
"version": "2.1.11",
"version": "2.1.12",
"description": "Fastest, most accurate & effecient user agent string parser, uses Browserscope's research for parsing",

@@ -47,3 +47,6 @@ "author": "Arnout Kazemier",

},
"pre-commit": ["test", "update"],
"pre-commit": [
"test",
"update"
],
"scripts": {

@@ -56,4 +59,5 @@ "test": "mocha $(find test -name '*.test.js')",

"dependencies": {
"lru-cache": "2.2.x"
"lru-cache": "2.2.x",
"tmp": "0.0.x"
}
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc