retrieveBrowserVersion() uses a weird indexOf(" ") , which is wrong for Mozilla 1.7.
Fixed version:
private double retrieveBrowserVersion(String userAgent) {
if(userAgent.indexOf("msie")>-1) {
String str = userAgent.substring(userAgent.indexOf("msie") + 5);
return Double.parseDouble(str.substring(0, str.indexOf(";")));
}
else {
String str = userAgent.substring(userAgent.indexOf("gecko") + 6);
int weirdSpace = str.indexOf(" ");
String versionStr = str.substring(0, (weirdSpace == -1 ? str.length() : weirdSpace));
double version = Double.parseDouble(versionStr);
return version;
}
}
or something like that .. i.e., if indexOf(" ") fails, just use the Gecko version string till the end of line.
Fixed version:
private double retrieveBrowserVersion(String userAgent) {
if(userAgent.indexOf("msie")>-1) {
String str = userAgent.substring(userAgent.indexOf("msie") + 5);
return Double.parseDouble(str.substring(0, str.indexOf(";")));
}
else {
String str = userAgent.substring(userAgent.indexOf("gecko") + 6);
int weirdSpace = str.indexOf(" ");
String versionStr = str.substring(0, (weirdSpace == -1 ? str.length() : weirdSpace));
double version = Double.parseDouble(versionStr);
return version;
}
}
or something like that .. i.e., if indexOf(" ") fails, just use the Gecko version string till the end of line.