Fixes for UTF-8 encoding issues (bug #957444, bug #961882, bug #962207, bug #964673, bug #965578).

This commit is contained in:
Tim Waugh 2013-05-21 17:27:13 +01:00
parent c38528a2cb
commit cfad2ffd71
5 changed files with 165 additions and 1 deletions

View File

@ -0,0 +1,25 @@
diff -up system-config-printer-1.4.1/cupshelpers/cupshelpers.py.utf8-961882 system-config-printer-1.4.1/cupshelpers/cupshelpers.py
--- system-config-printer-1.4.1/cupshelpers/cupshelpers.py.utf8-961882 2013-05-09 12:10:43.000000000 +0100
+++ system-config-printer-1.4.1/cupshelpers/cupshelpers.py 2013-05-21 17:19:30.156816163 +0100
@@ -526,6 +526,11 @@ class Device:
self.id = kw.get('device-id', '')
self.location = kw.get('device-location', '')
+ if type (self.info) == unicode:
+ # Convert unicode objects to UTF-8 encoding so they can be
+ # compared with other UTF-8 encoded strings (bug #957444).
+ self.info = self.info.encode ('utf-8')
+
uri_pieces = uri.split(":")
self.type = uri_pieces[0]
self.is_class = len(uri_pieces)==1
@@ -610,8 +615,7 @@ class Device:
return -1
result = cmp(bool(self.id), bool(other.id))
if not result:
- result = cmp(self.info.encode ('utf-8'),
- other.info.encode ('utf-8'))
+ result = cmp(self.info, other.info)
return result

View File

@ -0,0 +1,62 @@
diff -up system-config-printer-1.4.1/newprinter.py.utf8-962207 system-config-printer-1.4.1/newprinter.py
--- system-config-printer-1.4.1/newprinter.py.utf8-962207 2013-05-09 12:10:43.000000000 +0100
+++ system-config-printer-1.4.1/newprinter.py 2013-05-21 17:20:20.852036184 +0100
@@ -1632,7 +1632,7 @@ class NewPrinterGUI(GtkGUI):
def on_entNPName_changed(self, widget):
# restrict
- text = unicode (widget.get_text())
+ text = unicode (widget.get_text(), locale.getpreferredencoding ())
new_text = text
new_text = new_text.replace("/", "")
new_text = new_text.replace("#", "")
@@ -2516,7 +2516,7 @@ class NewPrinterGUI(GtkGUI):
allowed_chars = unicode (allowed_chars, locale.getpreferredencoding())
except UnicodeDecodeError:
allowed_chars = unicode (allowed_chars)
- origtext = unicode (entry.get_text())
+ origtext = unicode (entry.get_text(). locale.getpreferredencoding ())
new_text = origtext
for char in origtext:
if char not in allowed_chars:
@@ -3881,9 +3881,10 @@ class NewPrinterGUI(GtkGUI):
self.dec_spinner_task ()
if self.dialog_mode in ("class", "printer", "printer_with_uri"):
- name = unicode (self.entNPName.get_text())
- location = unicode (self.entNPLocation.get_text())
- info = unicode (self.entNPDescription.get_text())
+ enc = locale.getpreferredencoding ()
+ name = unicode (self.entNPName.get_text(), enc)
+ location = unicode (self.entNPLocation.get_text(), enc)
+ info = unicode (self.entNPDescription.get_text(), enc)
else:
name = self._name
diff -up system-config-printer-1.4.1/printerproperties.py.utf8-962207 system-config-printer-1.4.1/printerproperties.py
--- system-config-printer-1.4.1/printerproperties.py.utf8-962207 2013-05-09 12:10:45.000000000 +0100
+++ system-config-printer-1.4.1/printerproperties.py 2013-05-21 17:20:20.853036185 +0100
@@ -683,6 +683,9 @@ class PrinterPropertiesDialog(GtkGUI):
old_value = old_values[widget]
+ if type (old_value) == unicode:
+ old_value = old_value.encode (locale.getpreferredencoding ())
+
if old_value == value:
self.changed.discard(widget)
else:
@@ -1034,9 +1037,10 @@ class PrinterPropertiesDialog(GtkGUI):
for member in old_members:
self.cups.deletePrinterFromClass(member, name)
- location = self.entPLocation.get_text()
- info = self.entPDescription.get_text()
- device_uri = self.entPDevice.get_text()
+ enc = locale.getpreferredencoding ()
+ location = self.entPLocation.get_text().decode (enc)
+ info = self.entPDescription.get_text().decode (enc)
+ device_uri = self.entPDevice.get_text().decode (enc)
enabled = self.chkPEnabled.get_active()
accepting = self.chkPAccepting.get_active()

View File

@ -0,0 +1,30 @@
diff -up system-config-printer-1.4.1/statereason.py.utf8-964673 system-config-printer-1.4.1/statereason.py
--- system-config-printer-1.4.1/statereason.py.utf8-964673 2013-02-19 16:18:36.000000000 +0000
+++ system-config-printer-1.4.1/statereason.py 2013-05-21 17:20:50.123163282 +0100
@@ -1,6 +1,6 @@
#!/usr/bin/python
-## Copyright (C) 2007, 2008, 2009, 2010, 2012 Red Hat, Inc.
+## Copyright (C) 2007, 2008, 2009, 2010, 2012, 2013 Red Hat, Inc.
## Authors:
## Tim Waugh <twaugh@redhat.com>
## Jiri Popelka <jpopelka@redhat.com>
@@ -121,7 +121,7 @@ class StateReason:
try:
(title, text) = messages[self.get_reason ()]
try:
- text = text % self.get_printer ()
+ text = text.decode ('utf-8') % self.get_printer ()
except TypeError:
# Probably an incorrect translation, missing a '%s'.
pass
@@ -148,7 +148,8 @@ class StateReason:
except RuntimeError:
pass
- text = _("Printer '%s': '%s'.") % (self.get_printer (), reason)
+ text = (_("Printer '%s': '%s'.").decode ('utf-8') %
+ (self.get_printer (), reason))
return (title, text)
def get_tuple (self):

View File

@ -0,0 +1,32 @@
diff -up system-config-printer-1.4.1/printerproperties.py.utf8-965578 system-config-printer-1.4.1/printerproperties.py
--- system-config-printer-1.4.1/printerproperties.py.utf8-965578 2013-05-21 17:20:20.853036185 +0100
+++ system-config-printer-1.4.1/printerproperties.py 2013-05-21 17:21:56.763452869 +0100
@@ -65,10 +65,14 @@ class PrinterPropertiesDialog(GtkGUI):
'dialog-closed': ( GObject.SIGNAL_RUN_LAST, None, ()),
}
- printer_states = { cups.IPP_PRINTER_IDLE: _("Idle"),
- cups.IPP_PRINTER_PROCESSING: _("Processing"),
- cups.IPP_PRINTER_BUSY: _("Busy"),
- cups.IPP_PRINTER_STOPPED: _("Stopped") }
+ printer_states = { cups.IPP_PRINTER_IDLE:
+ _("Idle").decode ('utf-8'),
+ cups.IPP_PRINTER_PROCESSING:
+ _("Processing").decode ('utf-8'),
+ cups.IPP_PRINTER_BUSY:
+ _("Busy").decode ('utf-8'),
+ cups.IPP_PRINTER_STOPPED:
+ _("Stopped").decode ('utf-8') }
def __init__(self):
GObject.GObject.__init__ (self)
@@ -1635,7 +1639,8 @@ class PrinterPropertiesDialog(GtkGUI):
debugprint ("update printer properties")
printer = self.printer
self.entPMakeModel.set_text(printer.make_and_model)
- state = self.printer_states.get (printer.state, _("Unknown"))
+ state = self.printer_states.get (printer.state,
+ _("Unknown").decode ('utf-8'))
reason = printer.other_attributes.get ('printer-state-message', '')
if len (reason) > 0:
state += ' - ' + reason

View File

@ -1,12 +1,16 @@
Summary: A printer administration tool
Name: system-config-printer
Version: 1.4.1
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2+
URL: http://cyberelk.net/tim/software/system-config-printer/
Group: System Environment/Base
Source0: http://cyberelk.net/tim/data/system-config-printer/1.3/%{name}-%{version}.tar.xz
Patch1: system-config-printer-no-applet-in-gnome.patch
Patch2: system-config-printer-utf8-961882.patch
Patch3: system-config-printer-utf8-962207.patch
Patch4: system-config-printer-utf8-964673.patch
Patch5: system-config-printer-utf8-965578.patch
BuildRequires: cups-devel >= 1.2
BuildRequires: desktop-file-utils >= 0.2.92
@ -68,6 +72,13 @@ printers.
# Don't start the applet in GNOME.
%patch1 -p1 -b .no-applet-in-gnome
# Fixes for UTF-8 encoding issues (bug #957444, bug #961882,
# bug #962207, bug #964673, bug #965578).
%patch2 -p1 -b .utf8-961882
%patch3 -p1 -b .utf8-962207
%patch4 -p1 -b .utf8-964673
%patch5 -p1 -b .utf8-965578
%build
%configure --with-udev-rules
@ -167,6 +178,10 @@ touch %buildroot%{_localstatedir}/run/udev-configure-printer/usb-uris
exit 0
%changelog
* Tue May 21 2013 Tim Waugh <twaugh@redhat.com> 1.4.1-2
- Fixes for UTF-8 encoding issues (bug #957444, bug #961882,
bug #962207, bug #964673, bug #965578).
* Thu May 9 2013 Tim Waugh <twaugh@redhat.com> 1.4.1-1
- 1.4.1:
- Don't call into Gtk directly from scp-dbus-service (bug #951710).