Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Slowness in parsing user agent #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bt-wil opened this issue Mar 9, 2019 · 1 comment
Closed

Slowness in parsing user agent #71

bt-wil opened this issue Mar 9, 2019 · 1 comment

Comments

@bt-wil
Copy link

bt-wil commented Mar 9, 2019

Some user agent strings are causing the user agent parser to be really slow.

from ua_parser import user_agent_parser

ua_str = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_5 like Mac OS X) AppleWebKit/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 (KHTML, like Gecko) Version/5.1 Mobile/9334 Safari/7548.320"

s = time.time()
print(user_agent_parser.ParseUserAgent(ua_str))
print('took ', time.time() - s)
  • v0.7.3 took ~0.05s
  • v0.8.0 took ~7.0s
  • v0.8.0 took ~110s! with AppleWebKit/<400 digits>

The notable change was updating uap-core gitsubmodule from ce89c7637eeeb07b3464dbf40645bb3973723c0a to fc570f378e41063bad3bdf0532967743efc75b4b

After digging around, I've found that the issue is due to the regex addition in uap-core:

The latest regexes.xml altered the regex, and looks to have fixed the slowness issue.

PR for #70 looks to use the new regex which helps the issue.

@elsigh
Copy link
Contributor

elsigh commented Jan 9, 2020

maybe this is fixed now?

@elsigh elsigh closed this as completed Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants