You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Some user agent strings are causing the user agent parser to be really slow.
AppleWebKit/<400 digits>
The notable change was updating
uap-core
gitsubmodule fromce89c7637eeeb07b3464dbf40645bb3973723c0a
tofc570f378e41063bad3bdf0532967743efc75b4b
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.
The text was updated successfully, but these errors were encountered: