We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
2 parentsc92567b +79c7c54 commit187c172Copy full SHA for 187c172
index.js
@@ -415,10 +415,12 @@ function isSafe(userAgent) {
415
varconsecutive=0
416
,code=0;
417
418
+if(userAgent.length>1000)returnfalse;
419
+
420
for(vari=0;i<userAgent.length;i++){
421
code=userAgent.charCodeAt(i);
-// numbers between 0 and 9, letters between a and z
-if((code>=48&&code<=57)||(code>=97&&code<=122)){
422
+// numbers between 0 and 9, letters between a and z, spaces and control
423
+if((code>=48&&code<=57)||(code>=97&&code<=122)||code<=32){
424
consecutive++;
425
}else{
426
consecutive=0;
@@ -443,6 +445,10 @@ function isSafe(userAgent) {
443
445
*@api public
444
446
*/
447
exports.parse=functionparse(userAgent,jsAgent){
448
+if(userAgent&&userAgent.length>1000){
449
+userAgent=userAgent.substring(0,1000);
450
+}
451
452
if(!userAgent||!isSafe(userAgent))returnnewAgent();
453
454
varlength=agentparserslength