Thomas--F / BotTracker

BotTracker-Plugin for Piwik
GNU General Public License v3.0
33 stars 14 forks source link

Assure that useragent length limit is kept for extra stats table #73

Closed MichaIng closed 3 years ago

MichaIng commented 3 years ago

Similar to the URL length, also the user agent string length is limited to 100 bytes/characters. But it is currently not assured that this limit is kept before the database query is done.

There are user agents with much longer strings, e.g. "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1 (compatible; Baiduspider-render/2.0; +http://www.baidu.com/search/spider.html" with 211 characters. Similar to the URL, such strings are now truncated before the database query is done. This must not be done earlier, since the $ua variable is used for user agent ID estimation, where the identifying pattern must not be truncated.

This is a quick fix, while there might be smarter solutions, like increasing the allowed size of the useragent field, or removing specific parts from the string, which are known to be less relevant. E.g. with this solution, the above example would not contain the identifying "Baiduspider-render" anymore.