Permalink
Browse files

Add UA detection for modern iterations of Firefox Mobile.

Note that this changes how versions and browsers are detected. In
particular it relies on the Firefox desktop regex to parse the
version number, and then the browser (being mobile) is set by the
mobile regex, which doesn't parse a version. Order is important, and
is consistent. This could bite us in the future.
  • Loading branch information...
1 parent a43f775 commit 759148547ce063e4a9b26925edbb88c56d5059e1 @mythmon mythmon committed with willkg Aug 21, 2012
Showing with 7 additions and 10 deletions.
  1. +5 −8 apps/feedback/utils.py
  2. +2 −2 apps/input/__init__.py
View
@@ -33,18 +33,15 @@ def ua_parse(ua):
for browser in BROWSERS:
match = re.match(browser[1], ua)
if match:
+ detected['browser'] = browser[0]
try:
version = Version(match.group(2))
+ detected['version'] = str(version)
except:
- # Unable to parse version? No dice.
- return None
- detected = {
- 'browser': browser[0],
- 'version': str(version),
- }
- break
+ # Can't parse version? Try more.
+ pass
# Browser not recognized? Bail.
- if not detected:
+ if 'browser' not in detected or 'version' not in detected:
return None
# Detect Platform
View
@@ -125,13 +125,13 @@ class MOBILE:
UA_PATTERN_FIREFOX = (
r'^Mozilla.*(Firefox|Minefield|Namoroka|Shiretoko|GranParadiso|BonEcho|'
'Iceweasel|Fennec|MozillaDeveloperPreview)\/([^\s]*).*$')
-UA_PATTERN_MOBILE = r'^Mozilla.*(Fennec)\/([^\s]*)$'
+UA_PATTERN_MOBILE = r'^Mozilla.*(Fennec|Mobile|Tablet)'
# Order is important: Since Fennec is Firefox too, it'll match the second
# pattern as well, so we must detect it first.
BROWSERS = (
- (MOBILE, UA_PATTERN_MOBILE),
(FIREFOX, UA_PATTERN_FIREFOX),
+ (MOBILE, UA_PATTERN_MOBILE),
)
key = 'LATEST_FIREFOX_RELEASED_DEVEL_VERSION'

0 comments on commit 7591485

Please sign in to comment.