ufw 0.31: UnicodeDecodeError errors
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ufw |
Fix Released
|
High
|
Jamie Strandboge | ||
ufw (Ubuntu) |
Fix Released
|
High
|
Jamie Strandboge | ||
Precise |
Fix Released
|
High
|
Jamie Strandboge |
Bug Description
I'm sorry to say but apparently change introduced to resolve bug 921758 breaks ufw under some locales, for example sk and es,.
I've noticed it after running a test with various locales today…
I have language files in /usr/share/
Steps to reproduce.
1. add any rule ($ip - any ip)
ufw deny to $ip
2. 'ufw status' with 'sk' locale fails. Make sure you have the sk translation and it's used.
# LANG=sk ufw status
Traceback (most recent call last):
File "/usr/sbin/
ui = ufw.frontend.
File "/usr/lib/
self.backend = UFWBackendIptab
File "/usr/lib/
ufw.
File "/usr/lib/
self.
File "/usr/lib/
tmp[4], tmp[5], dtype)
File "/usr/lib/
self.
File "/usr/lib/
err_msg = _("Bad port '%s'") % (port)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2: ordinal not in range(128)
Different commands fail in different places. For example when you make this change in common.py, line 186:
- err_msg = _("Bad port '%s'") % (port)
+ err_msg = _("Bad port '%s'") % (port.encode())
(this is only an example, not suggested fix)
that works for this command, but another error occurs:
Traceback (most recent call last):
File "/usr/sbin/
res = ui.do_action(
File "/usr/lib/
res = self.get_status()
File "/usr/lib/
out = self.backend.
File "/usr/lib/
full_str += s
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 33: ordinal not in range(128)
Why locale matters - hm, I'm not sure, but perhaps it occurs when it has a translated string (from gettext()) with non-Latin letters and tries to mix it or something with a non-Unicode string -- that could be why it doesn't happen in my tested cases with pl locale - Polish has diacritics, but its ufw translation isn't rich. Please keep in mind I didn't investigate it much, but it looks like this from a shallow view. I'm attaching a file that follows step 2 (after step 1 is done) with different LANG values in case it will be useful.
Related branches
Changed in ufw: | |
assignee: | nobody → Jamie Strandboge (jdstrand) |
importance: | Undecided → High |
status: | New → Confirmed |
Changed in ufw (Ubuntu): | |
assignee: | nobody → Jamie Strandboge (jdstrand) |
status: | New → In Progress |
importance: | Undecided → High |
milestone: | none → ubuntu-12.04-beta-2 |
tags: | added: rls-p-tracking |
Changed in ufw: | |
status: | Confirmed → Fix Committed |
So, even this fails:
sudo LC_ALL=tr_TR.UTF-8 ufw status
So it seems we did not actually fix the original bug correctly. I have test cases now to test this and will revert the fix.