← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~sinzui/launchpad/unicode-project-group-bug into lp:launchpad

 

Curtis Hovey has proposed merging lp:~sinzui/launchpad/unicode-project-group-bug into lp:launchpad.

Commit message:
Reporting a bug from a project group accepts unicode bug summaries

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1077195 in Launchpad itself: "Can not report a bug from a project group with unicode"
  https://bugs.launchpad.net/launchpad/+bug/1077195

For more details, see:
https://code.launchpad.net/~sinzui/launchpad/unicode-project-group-bug/+merge/134154

The report a bug from a project group form fails if the summary
contains unicode. form forwards the request to the selected project,
but the summary is assumed to be ascii. The call to URLEncode fails
when give unicode.

--------------------------------------------------------------------

RULES

    Pre-implementation: no one
    * ProjectGroupFileBugGuidedView.projectgroup_search_action needs
      to decode the summary before passing it to URLEncode.

    ADDENDUM:
    * The redirect does not go to the bug domain. It should.

QA

    * Visit https://bugs.qastaging.launchpad.net/ubuntu-fr-website-project/+filebug
    * Choose Forum Ubuntu-fr
    * Enter "Le bouton liste à puces n'est pas correct" in the summary field.
    * Choose Continue
    * Verify the page redirect to the Forum Ubuntu-fr project and
      shows the matches and/or bug form.
    * Verify the url using the bugs host.

LINT

    lib/lp/bugs/browser/bugtarget.py
    lib/lp/bugs/browser/tests/test_bugtarget_filebug.py

LoC

    I have a 3000 line credit this week.

TEST

    ./bin/test -vvc -t ProjectGroup lp.bugs.browser.tests.test_bugtarget_filebug

IMPLEMENTATION

I discovered that the redirect url went to the wrong host when I was
investigating a fix. I added the missing rootsite arg and test for it.
I expected the test to verify that the summary is encoded as utf8 before
passing it to URLEncode(). Note that will bug tags have to be unicode in
tests, the validator requires that they are ascii; it is not possibly
to have a similar problem with bug tags.
    lib/lp/bugs/browser/bugtarget.py
    lib/lp/bugs/browser/tests/test_bugtarget_filebug.py
-- 
https://code.launchpad.net/~sinzui/launchpad/unicode-project-group-bug/+merge/134154
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/unicode-project-group-bug into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py	2012-11-06 05:56:49 +0000
+++ lib/lp/bugs/browser/bugtarget.py	2012-11-13 17:00:47 +0000
@@ -1081,10 +1081,12 @@
     @action("Continue", name="projectgroupsearch")
     def projectgroup_search_action(self, action, data):
         """Redirect to the chosen product's form."""
-        base = canonical_url(data['product'], view_name='+filebug')
+        base = canonical_url(
+            data['product'], view_name='+filebug', rootsite='bugs')
+        title = data['title'].encode('utf8')
         query = urllib.urlencode([
             ('field.actions.search', 'Continue'),
-            ('field.title', data['title']),
+            ('field.title', title),
             ('field.tags', ' '.join(data['tags'])),
             ])
         url = '%s?%s' % (base, query)

=== modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py'
--- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py	2012-11-06 04:34:48 +0000
+++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py	2012-11-13 17:00:47 +0000
@@ -813,6 +813,51 @@
         self.assertIn("Thank you for your bug report.", msg)
 
 
+class ProjectGroupFileBugGuidedViewTestCase(TestCaseWithFactory):
+
+    layer = DatabaseFunctionalLayer
+
+    def makeProjectGroupFileBugView(self, product_name, bug_title, tags=''):
+        project_group = self.factory.makeProject()
+        owner = project_group.owner
+        product = self.factory.makeProduct(
+            owner=owner, name=product_name, project=project_group)
+        with person_logged_in(owner):
+            product.official_malone = True
+        form = {
+            'field.product': product_name,
+            'field.title': bug_title,
+            'field.tags': tags,
+            'field.actions.projectgroupsearch': 'Continue',
+            }
+        view = create_initialized_view(
+            project_group, name='+filebug', form=form, rootsite='bugs')
+        return view
+
+    def test_redirect_to_project(self):
+        # The view redirects to the select sub project.
+        view = self.makeProjectGroupFileBugView('fnord', 'A bug', u'is os')
+        response = view.request.response
+        self.assertEqual(302, response.getStatus())
+        self.assertEqual(
+            'http://bugs.launchpad.dev/fnord/+filebug?'
+            'field.actions.search=Continue&'
+            'field.title=A+bug&'
+            'field.tags=is+os',
+            response.getHeader('Location'))
+
+    def test_redirect_to_project_unicode_summary(self):
+        # The summary is reencoded properly when it contains unicode.
+        view = self.makeProjectGroupFileBugView('fnord', u'caf\xe9', '')
+        response = view.request.response
+        self.assertEqual(
+            'http://bugs.launchpad.dev/fnord/+filebug?'
+            'field.actions.search=Continue&'
+            'field.title=caf%C3%A9&'
+            'field.tags=',
+            response.getHeader('Location'))
+
+
 class TestFileBugRequestCache(TestCaseWithFactory):
     # Tests to ensure the request cache contains the expected values for
     # file bug views.


Follow ups