Edgewall Software

Ticket #6535 (closed defect: fixed)

Opened 13 months ago

Last modified 13 months ago

Webadmin fails to save uft-8 (UnicodeDecodeError:)

Reported by: ilias@… Owned by: cboos
Priority: normal Milestone: 0.11
Component: general Version: 0.11b1
Severity: normal Keywords: unicode
Cc:

Description

UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 0: ordinal not in range(128)

Reproduction

  • got to admin/general/basics
  • add an utf-8 project name (e.g. copy/pase this one: Σχέδιο
  • Apply Changes

Request parameters:

{'__FORM_TOKEN': u'd9123783c98bf73d5a080637',
 'cat_id': None,
 'descr': u'Please add Project Description',
 'name': u'\u03a3\u03c7\u03ad\u03b4\u03b9\u03bf \u039f\u03c1\u03b8\u03bf\u03bd\u03bf\u03bc\u03af\u03b1\u03c2',
 'panel_id': None,
 'path_info': None,
 'url': u'http://example.org/'}

System Information

Trac 0.11b1
Python 2.4 (#1, Mar 22 2005, 21:42:42)
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)]
setuptools 0.6c7
SQLite 3.3.4
pysqlite 2.1.3
Genshi 0.5dev-r700
Pygments 0.7.1
Subversion 1.1.3 (r12730)

Attachments

fix-config-save-r6367.diff (1.1 KB) - added by cboos 13 months ago.
Enforce unicode comparison between current value and default value from parent config

Change History

Changed 13 months ago by cboos

Works fine for me ... My test project name was already "Trac Dével (ü)", now it's "Trac Dével (ü) Σχέδιο" ;-)

Can you show us the backtrace?

Changed 13 months ago by ilias@…

here it is

Python Traceback

Traceback (most recent call last):
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/web/main.py", line 398, in _dispatch_request
    dispatcher.dispatch(req)
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/web/main.py", line 195, in dispatch
    resp = chosen_handler.process_request(req)
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/admin/web_ui.py", line 108, in process_request
    path_info)
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/admin/web_ui.py", line 187, in render_admin_panel
    self.config.save()
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/config.py", line 184, in save
    if current is not False and current != default:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 0: ordinal not in range(128)

Changed 13 months ago by ilias@…

more detailed

Code fragment:

 179. default = None
 180. if self.parent:
 181. default = self.parent.get(section, option)
 182. current = self.parser.has_option(section, option) and \
 183. self.parser.get(section, option)
 184. if current is not False and current != default:
 185. options.append((option, current))
 186. if options:
 187. sections.append((section, sorted(options)))
 188.  
 189. fileobj = open(self.filename, 'w')

Local variables:
Name	Value
current 	'\xce\xa3\xcf\x87\xce\xad\xce\xb4\xce\xb9\xce\xbf ...
default 	u'Please add the Name'
option 	'name'
options 	[]
section 	'project'
sections 	[('account-manager', [('password_store', 'HtPasswdStore')]), ...
self 	<Configuration ...

Changed 13 months ago by cboos

  • keywords unicode added
  • owner changed from cmlenz to jonas
  • component changed from webadmin to general
  • milestone set to 0.11

Ok, I see the problem (self.parent gives unicode back, and self.parser.get gives str back; the comparison promotes the str to unicode the automatic way)

Changed 13 months ago by ilias@…

but why on my site and not at yours?

Changed 13 months ago by cboos

Enforce unicode comparison between current value and default value from parent config

Changed 13 months ago by cboos

  • owner changed from jonas to cboos
  • status changed from new to assigned

I didn't have a parent config (i.e no [inherit] file =...) for that environment.

Could you please try the following fix?

attachment:fix-config-save-r6367.diff

Changed 13 months ago by ilias@…

I've tried the fix, works fine on my side.

Thanks a lot.

Changed 13 months ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed

You're welcome, thanks for the report.

Fixed in [6368].

Add/Change #6535 (Webadmin fails to save uft-8 (UnicodeDecodeError:))

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.