Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

UAParser.php fails for Symbian device user agents #30

Closed
michael-grunder opened this issue Jun 19, 2012 · 1 comment
Closed

UAParser.php fails for Symbian device user agents #30

michael-grunder opened this issue Jun 19, 2012 · 1 comment

Comments

@michael-grunder
Copy link

Hey guys,

We just started feeding live data through the UAParser and it's working quite well for us. The only issue we have had thus far comes from Symbian related devices (Nokia):

This user agent string, for example:

Mozilla/5.0 (SymbianOS/9.1; U; en) AppleWebKit/413 (KHTML, like Gecko) Safari/413

Fails in UAParser.php with an "Undefined offset" error:

PHP Notice: Undefined offset: 1 in .../ua_parser/php/UAParser.php on line 307

Which think is happening because in the YAML there is this defined regex block:

 - regex: 'Symbian'
    device_replacement: 'Nokia'

If you change to the following, it seems to work:

 - regex: '(Symbian)'
    device_replacement: 'Nokia'

In other words that one wasn't defining a closure, so there would never be $matches[1] defined. Now, I don't know as much about user agents as you guys so is this a proper change, or should it perhaps be done another way?

Cheers,
Mike

@dmolsen
Copy link
Collaborator

dmolsen commented Jun 20, 2012

Rather than fix regexes.yaml I ended up fixing my PHP lib instead. This way if I forgot parens in the future it won't break again. Thanks much for letting us know about the issue and providing good details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants