burak / CPAN-Parse-HTTP-UserAgent

0 stars 3 forks source link

Blows up on bad user agent #3

Open nfg opened 5 years ago

nfg commented 5 years ago

Hey! So, I don't know where this user agent comes from, but it breaks Parse::HTTP::UserAgent:

#!/usr/bin/env perl

use strict; use warnings;
use Parse::HTTP::UserAgent 0.42;

my $bad_useragent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Mobile/15A372kalturaNativeCordovaPlayer';
Parse::HTTP::UserAgent->new($bad_useragent);

# Causes:
# Invalid version format (fractional part required) at /home/nfg/.plenv/versions/5.28.0/lib/perl5/site_perl/5.28.0/Parse/HTTP/UserAgent.pm line 351.
#  at blow.pl line 7.
nfg commented 5 years ago

I added some debug statements, and it looks like $v is initially 15A372kalturaNativeCordovaPlayer, and becomes 15.v.v.. It looks like it's picking up the "v"s from the rest of the string.