lennerd/vipx-bot-detect — pull request #2 by mbfisher (2013-04-25 09:17:15+00:00)
Title: Add agentMatch definition to bots with no IPs

Lots of the bots in Resources/metdata/extended_bot.yml have defintions
that look like:

SiteSell:
agent: ''
ip: null
type: bot
meta: { website: 'http://www.sitesell.com/sbider.html' }

Because the default value for Metadata::$agentMatch set by
MetadataInterface is 'regexp', when `agent` is empty the default
behaviour of Metadata::match() is to perform a match like:

preg_match('##', $agent);

Empty regexes always match in PHP:

php > echo preg_match('##', 'foo') ? 'match' : 'no match';
match

This means that when using the extended.yml configuration the first bot
with configuration as above is matched and all requests are deemed to be
being made by a bot.

This commit proposes a solution to the issue by configuring the
`agent_match` property as 'exact' on bots that have an empty string
configured as the user agent:

SiteSell:
agent: ''
agent_match: exact
ip: null
type: bot
meta: { website: 'http://www.sitesell.com/sbider.html' }

This overrides the default pattern matching behaviour and prevents the
empty bots from being matched.