Bug#596691: system-config-printer: could not handle a printer share name with non-ASCII characters on SMB network
Morita Sho
morita-pub-en-debian at inz.sakura.ne.jp
Mon Sep 13 12:49:58 UTC 2010
Package: system-config-printer
Version: 1.2.3-2
Severity: normal
Tags: patch
Hi,
I have a printer on SMB network.
When I try to add this printer using system-config-printer, I got an error (described below).
The share name for my printer on SMB network is "プリンタ" and the error message says that it is a Unicode-related problem.
(Note: "プリンタ" means the Japanese word "Printer". It is the default printer share name on Windows Japanese locale.)
I suspected that the problem appeared due to the printer share name contains a non-ASCII character in it.
Here is how to reproduce the problem:
* Run system-config-printer.
* Add printer.
* Select "Windows Printer via SAMBA"
* Click "Browse..." button.
* Select WORKGROUP -> NAME -> プリンタ.
* The smb:// text field will be filled with "WORKGROUP/NAME/%E3%83%97%E3%83%AA%E3%83%B3%E3%82%BF"
(Note: %E3%83%97%E3%83%AA%E3%83%B3%E3%82%BF is a url-encoded string for the UTF-8 string "プリンタ")
* Click "Forward". Nothing happens. But system-config-printer outputs the following error message in the terminal:
/usr/lib/python2.6/urllib.py:1224: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
res = map(safe_map.__getitem__, s)
Traceback (most recent call last):
File "/usr/bin/system-config-printer", line 4368, in on_btnNPForward_clicked
self.nextNPTab()
File "/usr/bin/system-config-printer", line 4392, in nextNPTab
uri = SMBURI (uri=uri[6:]).sanitize_uri ()
File "/usr/share/system-config-printer/smburi.py", line 70, in sanitize_uri
return self._construct (group, host, share)
File "/usr/share/system-config-printer/smburi.py", line 62, in _construct
uri += "/" + _urlquote (share)
File "/usr/share/system-config-printer/smburi.py", line 26, in _urlquote
q = urllib.quote (x)
File "/usr/lib/python2.6/urllib.py", line 1224, in quote
res = map(safe_map.__getitem__, s)
KeyError: u'\xe3'
After some investigations, I noticed that the string passed to SMBURI is a 'unicode' string. (type(uri) == 'unicode')
Then sanitize_uri() function tries to url-decode the string "%E3%83%97%E3%83%AA%E3%83%B3%E3%82%BF".
Since "%E3%83%97%E3%83%AA%E3%83%B3%E3%82%BF" is a url-encoded string for an UTF-8 string "プリンタ", url-decoding the string "%E3%83%97%E3%83%AA%E3%83%B3%E3%82%BF" generates a UTF-8 (not a Unicode) string "プリンタ".
Thus, the string generated by decoding "%E3%83%97%E3%83%AA%E3%83%B3%E3%82%BF" will be invalid Unicode string.
Working with a UTF-8 string which is marked as Unicode string will raises an exception. I think a UTF-8 string must be marked as a "UTF-8".
The following patch should fix the problem.
--- system-config-printer-1.2.3/smburi.py.orig 2010-09-13 21:03:52.000000000 +0900
+++ system-config-printer-1.2.3/smburi.py 2010-09-13 21:04:04.000000000 +0900
@@ -34,6 +34,7 @@
uri=None,
group='', host='', share='', user='', password=''):
if uri:
+ uri = uri.encode( "utf-8" )
if group or host or share or user or password:
raise RuntimeError
Regards,
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.32-5-686 (SMP w/1 CPU core)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages system-config-printer depends on:
ii gnome-icon-theme 2.30.3-1 GNOME Desktop icon theme
ii python 2.6.6-1 interactive high-level object-orie
ii python-cups 1.9.48-1 Python bindings for CUPS
ii python-cupshelpers 1.2.3-2 Python utility modules around the
ii python-dbus 0.83.1-1 simple interprocess messaging syst
ii python-glade2 2.17.0-4 GTK+ bindings: Glade support
ii python-gnome2 2.28.1-1 Python bindings for the GNOME desk
ii python-gtk2 2.17.0-4 Python bindings for the GTK+ widge
ii python-notify 0.1.1-2+b2 Python bindings for libnotify
ii python-support 1.0.9 automated rebuilding support for P
Versions of packages system-config-printer recommends:
pn cups-pk-helper <none> (no description available)
pn system-config-printer-udev <none> (no description available)
Versions of packages system-config-printer suggests:
ii python-gnomekeyring 2.30.0-1+b1 Python bindings for the GNOME keyr
ii python-smbc 1.0.6-1 Python bindings for the Samba clie
pn sessioninstaller <none> (no description available)
-- no debconf information
More information about the pkg-gnome-maintainers
mailing list