#1298 closed defect (fixed)

WUI cannot handle non-ASCII node nicknames

Reported by: zooko Owned by: davidsarah
Priority: major Milestone: 1.10.0
Component: code-frontend-web Version: 1.8.1
Keywords: unicode wui Cc:
Launchpad Bug:

Description

I used a non-ascii character in the nickname of my node in tahoe.cfg:

/usr/lib/python2.6/dist-packages/nevow/rend.py, line 777 in string
775
776 def string(context, data):
777    return context.tag.clear()[str(data)]
778
Locals
data	u'Zooko\'s ec2 micro instance named "\u03b12"'
context	WovenContext(tag=Tag(u'td', attributes={u'class': u'nickname mine'}), remembrances={'nevow.inevow.IData': u'Zooko\'s ec2 micro instance named "\u03b12"'})
Globals
string	<function string at 0xa0d95a4>
data	<function data at 0xa0d95dc>

<type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\u03b1' in position 34: ordinal not in range(128)

Attachments (1)

Exception.html (20.1 KB) - added by zooko at 2011-01-09T21:58:13Z.

Download all attachments as: .zip

Change History (13)

Changed at 2011-01-09T21:58:13Z by zooko

comment:1 Changed at 2011-01-11T07:27:46Z by warner

Sounds like welcome.xhtml line 19 (the n:render="string" n:data="my_nickname" clause) is the trouble. Maybe there's a different kind of n:render= tag that can mean "expect unicode", maybe even n:render="unicode". Or perhaps web/root.py (line 193, in data_my_nickname()) will need to be changed to encode the value that it returns.

comment:2 Changed at 2012-02-17T22:14:41Z by davidsarah

  • Component changed from unknown to code-frontend-web
  • Milestone changed from undecided to 1.10.0
  • Owner changed from nobody to davidsarah
  • Status changed from new to assigned

There probably needs to be a .decode('utf-8') in there.

It should probably just be context.tag.clear()[data].

Last edited at 2012-02-17T22:18:18Z by davidsarah (previous) (diff)

comment:3 Changed at 2012-02-17T22:16:07Z by davidsarah

  • Keywords wui added
  • Summary changed from can't decode non-ascii string in tahoe.cfg to WUI cannot handle non-ASCII node nicknames

comment:4 Changed at 2012-02-17T22:16:19Z by davidsarah

  • Keywords easy added

comment:5 Changed at 2012-04-01T03:47:34Z by davidsarah

  • Milestone changed from 1.11.0 to 1.10.0

comment:6 Changed at 2012-12-20T17:44:35Z by warner

looks trivial, if davidsarah doesn't land this by the weekend, I will.

comment:7 Changed at 2012-12-27T02:26:10Z by davidsarah

Working on a test now.

comment:8 Changed at 2012-12-27T05:35:32Z by davidsarah

  • Keywords review-needed added; easy removed
  • Owner changed from davidsarah to zooko
  • Status changed from assigned to new

This was more complicated than it looked; we have to change the n:render type because we cannot change Nevow. The storage status page had the same bug. Also, there was an additional unicode vs. str confusion in NativeStorageServer.get_nickname.

Anyway, it is done: https://github.com/tahoe-lafs/tahoe-lafs/pull/25

comment:9 Changed at 2012-12-27T17:22:11Z by amiller

  • Keywords approval-needed added; review-needed removed

Review:

  1. D-S fixed the bug by Replacing "n:render='string'" with "n:render='data'" in affected xhtml templates, which is a workaround to prevent Nevow from attempting an ascii decoding. D-S had to write a few new mockup structures in test_web.py to simulate the original bug. I ran the tests and looked to see if any other templates were missed.
  1. D-S removed a .decode('utf-8') from get_nickname, which is probably correct (since .decode('utf-8') is generally considered useless, doesn't exist in Python3, etc.), but what's the consequence? I put this line back in and all the tests still pass.

comment:10 Changed at 2012-12-27T17:43:50Z by amiller

  • Keywords reviewed added; approval-needed removed

comment:11 Changed at 2012-12-27T19:03:23Z by davidsarah

  • Owner changed from zooko to davidsarah
  • Status changed from new to assigned

Re: point 2, I made the system tests exercise the non-ASCII case with the real server code, and now these tests fail without the .decode('utf-8') change. Thanks, that was a big hole in the test coverage.

comment:12 Changed at 2012-12-27T19:13:25Z by davidsarah

  • Keywords reviewed removed
  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in 0d4a826, system tests improved in 5c4ca67.

Last edited at 2012-12-27T19:14:32Z by davidsarah (previous) (diff)
Note: See TracTickets for help on using tickets.