Conflict with unrecognised user agent strings

dryabov
12 years, 3 months ago
It's in plugins/mobile/amdd/amdd/amdd.php (function findByLevenshtein).
Now we test following patch:
$best = min(12, intval($ua_size/2));

(to prevent change of more than a half of characters), hope it will be sufficient.
openglobal
12 years, 3 months ago
I made this change and it hasn't fixed the problem:

 
//$best = 12; // maximum number of changes in UA string^M
$best = min(12, intval($ua_size/2));
 


OpenGlobal
dryabov
12 years, 3 months ago
Clear jos_mj_amdd_cache database table, most likely result was cached.
openglobal
12 years, 3 months ago
It's already empty.

OpenGlobal
dryabov
12 years, 3 months ago
And did you clear cookies (though, unlikely your script saves them)?
dryabov
12 years, 3 months ago
I've tested modified file locally, and it correctly detects "OpenGlobal" as desktop browser
openglobal
12 years, 3 months ago
My perl script (and I assume the W3C validator) doesn't store cookies.

Is this how the function should look?

 
private static function findByLevenshtein($ua, $devices)
{
$ua_size = strlen($ua);
 
$data = null;
 
//$best = 12; // maximum number of changes in UA string
$best = min(12, intval($ua_size/2));
foreach($devices as $device)
{
if(abs(strlen($device->ua) - $ua_size) > $best)
continue;
 
$current = levenshtein($ua, $device->ua);
if($current <= $best)
{
$best = $current;
$data = $device->data;
}
}
 
return $data;
}
 


OpenGlobal
2

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.