Subject: | Server logs many "Use of uninitialized value in division (/)" |
In my server logs I see many errors like:
Use of uninitialized value in division (/) at
/usr/local/share/perl/5.8.4/HTTP/BrowserDetect.pm line 142.
Use of uninitialized value in modulus (%) at
/usr/local/share/perl/5.8.4/HTTP/BrowserDetect.pm line 143.
These are casued by an unknown browser which reports itself as:
Mozilla/5.0 (SymbianOS/9.1; U; en-us) AppleWebKit/413 (KHTML, like
Gecko) Safari/413 UP.Link/6.3.1.15.0
i.e. Safari with no minor version number.
I have patched the code to make it more robust in this respect. See
attached diff output.
Subject: | diff-BrowserDetect-0.99.txt |
*** BrowserDetect.pm 2008-12-08 10:20:54.000000000 +0000
--- orig.BrowserDetect.pm 2007-02-22 16:49:51.000000000 +0000
***************
*** 135,147 ****
($safari_build,$safari_minor) = ($ua =~ /
safari
\/
! ( [\d]+ ) # Major version number is everything before first dot
! (?: \. # The first dot
! ( [\d]+ ))? # Minor version number is digits after first dot
/x);
! $major = int(($safari_build || 0) / 100);
! $minor = int(($safari_build || 0) % 100) / 100;
! $beta = $safari_minor || 0;
#print "major=$major minor=$minor beta=$beta\n";
}
--- 135,147 ----
($safari_build,$safari_minor) = ($ua =~ /
safari
\/
! ( [^\.]* ) # Major version number is everything before first dot
! (?: # The first dot
! ( [\d]* ))? # Minor version nnumber is digits after first dot
/x);
! $major = int($safari_build / 100);
! $minor = int($safari_build % 100) / 100;
! $beta = $safari_minor;
#print "major=$major minor=$minor beta=$beta\n";
}
***************