1773690 - cups-genppdupdate doesnt work for non-utf-8 PPDs
This commit is contained in:
parent
4312cbc7af
commit
8a6abe57fd
@ -255,6 +255,23 @@ def parse_options():
|
||||
|
||||
return args
|
||||
|
||||
def check_encoding(filename):
|
||||
import chardet
|
||||
|
||||
with open(filename, 'rb') as f:
|
||||
charenc = chardet.detect(f.read())['encoding']
|
||||
|
||||
if debug & 1:
|
||||
print("File encoding: {}".format(charenc))
|
||||
|
||||
if charenc in ['ascii', 'utf-8']:
|
||||
return 'utf-8'
|
||||
else:
|
||||
if debug & 1:
|
||||
print("Trying to use latin1 for decoding {}".format(charenc))
|
||||
|
||||
return 'latin1'
|
||||
|
||||
def update_ppd (ppd_source_filename):
|
||||
global ppd_dest_filename
|
||||
global ppd_out_dir
|
||||
@ -271,7 +288,8 @@ def update_ppd (ppd_source_filename):
|
||||
ppd_dest_filename = "%s/%s" % (ppd_out_dir,
|
||||
os.path.basename (ppd_dest_filename))
|
||||
|
||||
orig = open (ppd_source_filename, encoding="utf-8")
|
||||
fenc = check_encoding(ppd_source_filename)
|
||||
orig = open(ppd_source_filename, encoding=fenc)
|
||||
orig_metadata = os.fstat (orig.fileno ())
|
||||
if debug & 1:
|
||||
print ("Source Filename: %s" % ppd_source_filename)
|
||||
@ -284,7 +302,17 @@ def update_ppd (ppd_source_filename):
|
||||
region = ""
|
||||
valid = 0
|
||||
orig_locale = ""
|
||||
for line in orig.readlines ():
|
||||
|
||||
try:
|
||||
orig_lines = orig.readlines()
|
||||
except UnicodeDecodeError:
|
||||
if debug & 1:
|
||||
print('PPD {} has an unexpected enconding, '
|
||||
'skipping.'.format(ppd_source_filename))
|
||||
|
||||
return -1
|
||||
|
||||
for line in orig_lines:
|
||||
line.rstrip ()
|
||||
if line.find ("*StpLocale:") != -1:
|
||||
match = re.search ("\*StpLocale:\s*\"(.*)\"$", line)
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- gutenprint-5.2.12/src/cups/cups-genppdupdate.in.python36syntax
|
||||
+++ gutenprint-5.2.12/src/cups/cups-genppdupdate.in
|
||||
@@ -287,7 +287,7 @@ def update_ppd (ppd_source_filename):
|
||||
for line in orig.readlines ():
|
||||
for line in orig_lines:
|
||||
line.rstrip ()
|
||||
if line.find ("*StpLocale:") != -1:
|
||||
- match = re.search ("\*StpLocale:\s*\"(.*)\"$", line)
|
||||
|
@ -4,7 +4,7 @@
|
||||
Name: gutenprint
|
||||
Summary: Printer Drivers Package
|
||||
Version: 5.3.3
|
||||
Release: 6%{?dist}
|
||||
Release: 7%{?dist}
|
||||
URL: http://gimp-print.sourceforge.net/
|
||||
Source0: http://downloads.sourceforge.net/gimp-print/%{name}-%{version}.tar.xz
|
||||
# Post-install script to update CUPS native PPDs.
|
||||
@ -244,6 +244,9 @@ exit 0
|
||||
%{_mandir}/man8/cups-genppd*8*.gz
|
||||
|
||||
%changelog
|
||||
* Fri Nov 06 2020 Zdenek Dohnal <zdohnal@redhat.com> - 5.3.3-7
|
||||
- 1773690 - cups-genppdupdate doesnt work for non-utf-8 PPDs
|
||||
|
||||
* Thu Nov 05 2020 Zdenek Dohnal <zdohnal@redhat.com> - 5.3.3-6
|
||||
- make is no longer in buildroot by default
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user