Assure that useragent length limit is kept for extra stats table #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.