Hi list,

I'm using user_agent_parser.py from the latest stable version.

I have this user agent:

"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0"

I cannot understand why the code looks for the Opera user agent (I
have not read carefully the code) but it fails with this error:

  File 
"C:\Users\Collaboratore\Documents\HotSpot\MANAGER\web2py\gluon\contrib\user_agent_parser.py",
line 134, in getVersion
    return agent.split(self.look_for)[1][1:].split(' ')[0]
IndexError: list index out of range

Clearly the code has a problem:

class Opera(Browser):
    look_for = "Opera"
    def getVersion(self, agent):
                return agent.split(self.look_for)[1][1:].split(' ')[0]

This agent.split(self.look_for)[1] raise an exception when look_for
returns nothing (as in my case).

I think it should be a sort of checking prior calling getVersion, or
call getVersion only when the useragent is really Opera!

I'll look forward into the code and I'll try to look for a solution.

Thank you!

Reply via email to