Merge lp:~henninge/launchpad/devel-644872-unicode-error-in-search-text into lp:launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Henning Eggers | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 12966 | ||||
Proposed branch: | lp:~henninge/launchpad/devel-644872-unicode-error-in-search-text | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
177 lines (+58/-29) 2 files modified
lib/lp/answers/browser/questiontarget.py (+4/-4) lib/lp/answers/browser/tests/test_questiontarget.py (+54/-25) |
||||
To merge this branch: | bzr merge lp:~henninge/launchpad/devel-644872-unicode-error-in-search-text | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Graham Binns (community) | code | Approve | |
Review via email: mp+59783@code.launchpad.net |
Commit message
[r=gmb][bug=644872] Handle non-ascii strings in links to FAQs on an answers search page.
Description of the change
= Summary =
Searching for a non-ascii term caused a problem when there was lso an
FAQ for that term. The view method that created the link could not
handle non-ascii code.
== Proposed fix ==
Encode the string as utf-8. If the string is not unicode, this is a nop.
== Tests ==
I cleaned up the test module for questiontarget and added a test for
this bug. It really just needs to make sure that no exception gets
raised.
bin/test -vvcm lp.answers.
== Demo and Q/A ==
Search for "português" on http://
It should not raise an exception anymore.
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
This is potentially buggy: .encode( 'utf8') .encode( 'utf8')
>>> print u'foo\xce'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
3: ordinal not in range(128)
Do we know that the thing being encoded is always unicode? If so, the
patch is fine. If it /might be/ bytes already re-encoding would go
boom.