Skip to content

Commit

Permalink
Fix bug 1022972 - strip leading "rv:" from version
Browse files Browse the repository at this point in the history
Old Firefox clients may prefix their version with "rv:". This patch
strips that before performing a version compare.
  • Loading branch information
indygreg committed Jun 11, 2014
1 parent 5215673 commit b74d40a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bedrock/firefox/tests/test_base.py
Expand Up @@ -475,6 +475,14 @@ def test_fx_31(self, render_mock):
template = render_mock.call_args[0][1]
eq_(template, ['firefox/australis/whatsnew-no-tour.html'])

@override_settings(DEV=True)
def test_rv_prefix(self, render_mock):
"""Prefixed oldversion shouldn't impact version sniffing."""
req = self.rf.get('/en-US/firefox/whatsnew/?oldversion=rv:10.0')
self.view(req, fx_version='30.0')
template = render_mock.call_args[0][1]
eq_(template, ['firefox/australis/whatsnew-tour.html'])

@override_settings(DEV=False)
def test_fx_australis_secure_redirect(self, render_mock):
"""Should redirect to https: for 29.0."""
Expand Down Expand Up @@ -766,6 +774,9 @@ def test_whatsnew_tour_oldversion(self):
response = self.client.get(self.url + '?oldversion=4.0', HTTP_USER_AGENT=self.user_agent)
self.assertIn(self.expected, response.content)

response = self.client.get(self.url + '?oldversion=rv:10.0', HTTP_USER_AGENT=self.user_agent)
self.assertIn(self.expected, response.content)

response = self.client.get(self.url + '?oldversion=29.0', HTTP_USER_AGENT=self.user_agent)
self.assertNotIn(self.expected, response.content)

Expand Down
3 changes: 3 additions & 0 deletions bedrock/firefox/views.py
Expand Up @@ -430,6 +430,9 @@ def get_template_names(self):
fc_ctx = funnelcake_param(self.request)
f = fc_ctx.get('funnelcake_id', 0)
oldversion = self.request.GET.get('oldversion', '')
# old versions of Firefox sent a prefixed version
if oldversion.startswith('rv:'):
oldversion = oldversion[3:]
versions = ('29.', '30.', '31.')

if version == '29.0a1':
Expand Down

0 comments on commit b74d40a

Please sign in to comment.