Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the HTTP-BrowserDetect CPAN distribution.

Report information
The Basics
Id: 31847
Status: resolved
Priority: 0/
Queue: HTTP-BrowserDetect

People
Owner: Nobody in particular
Requestors: jmc-0606 [...] milibyte.co.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: os_string() returns "Unix" for some variants of MSIE and Windows
Date: Mon, 24 Dec 2007 14:50:11 +0000
To: bug-HTTP-BrowserDetect [...] rt.cpan.org.
From: Mike Clarke <jmc-0606 [...] milibyte.co.uk>
I'm ising HTTP::BrowserDetect in a perl script for analysing our Apache logs. os_string() incorrectly returns "Unix" for the following user agent strings: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Google Wireless Transcoder;) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Tesco; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Supplied by Tesco.net; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Tesco; .NET CLR 1.1.4322) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Sky Broadband; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; Tesco) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Supplied by Tesco.net; YPC 3.2.0; SV1; yplus 5.3.04b) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Tesco; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Supplied by Tesco.net) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Tesco; YPC 3.2.0; .NET CLR 1.1.4322; yplus 5.3.04b) I've attached a script which reproduces the problem. The problem appears to be due to the use of index() to locate substrings in the agent string. The characters "sco" in Tesco and Transcoder cause $tests->{SCO} to return a match at line 351. Perhaps it would be safer to use regular expressions for all the tests instead of index? As a workaround for this particular problem I've changed line 351 to: $tests->{SCO} = ($ua =~ /\Wsco\W/); --------------------------------------------------------------------------------------- System info: HTTP::BrowserDetect version is 0.99 kestrel:/home/mike/stats% perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=freebsd, osvers=6.2-release-p4, archname=i386-freebsd-64int uname='freebsd kestrel.lan 6.2-release-p4 freebsd 6.2-release-p4 #0: thu apr 26 17:40:53 utc 2007 root@i386-builder.daemonology.net:usrobjusrsrcsysgeneric i386 ' config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-O2 -fno-strict-aliasing -pipe -Ud_dosuid -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=undef uselongdouble=undef usemymalloc=y, bincompat5005=undef Compiler: cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include', optimize='-O2 -fno-strict-aliasing -pipe ', cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include' ccversion='', gccversion='3.4.6 [FreeBSD] 20060305', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lgdbm -lm -lcrypt -lutil perllibs=-lm -lcrypt -lutil libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE' cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MYMALLOC PERL_MALLOC_WRAP USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO Locally applied patches: defined-or Built under freebsd Compiled at Oct 16 2007 21:48:48 @INC: /usr/local/lib/perl5/5.8.8/BSDPAN /usr/local/lib/perl5/site_perl/5.8.8/mach /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.8/mach /usr/local/lib/perl5/5.8.8 . . kestrel:/home/mike/stats% uname -a FreeBSD kestrel.lan 6.2-STABLE FreeBSD 6.2-STABLE #1: Thu Nov 29 18:12:11 GMT 2007 root@kestrel.lan:/usr/obj/usr/src/sys/GENERIC i386 -- Mike Clarke

Message body is not shown because sender requested not to inline it.

Hi Mike, Thanks very much for this. I've applied your fix to the code. It will be available in 1.05, which should appear on the CPAN shortly. Thanks again, Olaf