← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/link-bug-tags-correctly-redux into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/link-bug-tags-correctly-redux into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #921175 in Launchpad itself: "Bug overview page tag links are not properly escaped, thus made useless"
  https://bugs.launchpad.net/launchpad/+bug/921175

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/link-bug-tags-correctly-redux/+merge/90044

Fix the mustache model so that it quotes bug tags in the URL portion.
-- 
https://code.launchpad.net/~stevenk/launchpad/link-bug-tags-correctly-redux/+merge/90044
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/link-bug-tags-correctly-redux into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py	2012-01-20 05:05:40 +0000
+++ lib/lp/bugs/browser/bugtask.py	2012-01-25 05:38:27 +0000
@@ -2280,7 +2280,7 @@
             'reporter': self.bug.owner.displayname,
             'status': self.status.title,
             'status_class': 'status' + self.status.name,
-            'tags': [{'url': base_tag_url + tag, 'tag': tag}
+            'tags': [{'url': base_tag_url + urllib.quote(tag), 'tag': tag}
                 for tag in self.bug.tags],
             'title': self.bug.title,
             }

=== modified file 'lib/lp/bugs/browser/tests/test_bugtask.py'
--- lib/lp/bugs/browser/tests/test_bugtask.py	2012-01-20 05:05:40 +0000
+++ lib/lp/bugs/browser/tests/test_bugtask.py	2012-01-25 05:38:27 +0000
@@ -2282,6 +2282,20 @@
                 key[2] in ('asc', 'desc'),
                 'Invalid order value: %r' % (key, ))
 
+    def test_tags_encoded_in_model(self):
+        # The tag name is encoded properly in the JSON.
+        product = self.factory.makeProduct(name='foobar')
+        bug = self.factory.makeBug(product=product, tags=['depends-on+987'])
+        with dynamic_listings():
+            view = self.makeView(bugtask=bug.default_bugtask)
+        cache = IJSONRequestCache(view.request)
+        tags = cache.objects['mustache_model']['items'][0]['tags']
+        expected_url = (
+            canonical_url(product, view_name='+bugs') +
+            '/?field.tag=depends-on%2B987')
+        self.assertEqual(
+            [{'url': expected_url, 'tag': u'depends-on+987'}], tags)
+
 
 class TestBugTaskExpirableListingView(BrowserTestCase):
     """Test BugTaskExpirableListingView."""