Bug#879115: hplip can't print jobs with unicode surrogate characters

2017-10-19 Thread John Hughes
Package: hplip
Version: 3.16.11+repack0-3
Severity: normal
Tags: upstream

Dear Maintainer,

   * What led up to the situation?

Tried to print PDF from evince

   * What exactly did you do (or not do) that was effective (or
 ineffective)?

Pressed the print button

   * What was the outcome of this action?

The print job "stopped"

   * What outcome did you expect instead?

Some printed paper.

Looking in the cups error_log I see:

D [19/Oct/2017:14:03:08 +0200] [Job 2204] File 
\"/usr/share/hplip/base/sixext.py\", line 109, in to_bytes_utf8
D [19/Oct/2017:14:03:08 +0200] [Job 2204] return s.encode(\"utf-8\")
D [19/Oct/2017:14:03:08 +0200] [Job 2204] UnicodeEncodeError: \'utf-8\' codec 
can\'t encode character \'\\udcc3\' in position 19: surrogates not allowed

This appears to be the launchpad bug:

https://bugs.launchpad.net/hplip/+bug/1498366

A simple, possibly incorrect, fix is:

--- /usr/share/hplip/base/sixext.py.orig2017-05-04 18:35:44.0 
+0200
+++ /usr/share/hplip/base/sixext.py 2017-10-19 17:40:51.946105373 +0200
@@ -106,7 +106,7 @@
 
 
 def to_bytes_utf8(s):
-return s.encode("utf-8")
+return s.encode("utf-8", errors="surrogateescape")
 
 
 def to_string_utf8(s):


-- Package-specific info:
Saving output in log file: /home/john/hp-check.log

HP Linux Imaging and Printing System (ver. 3.16.11)
Dependency/Version Check Utility ver. 15.1

Copyright (c) 2001-15 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

Note: hp-check can be run in three modes:
1. Compile-time check mode (-c or --compile): Use this mode before compiling 
the HPLIP supplied tarball (.tar.gz or .run) to determine if the proper 
dependencies are installed
to successfully compile HPLIP.  

   
2. Run-time check mode (-r or --run): Use this mode to determine if a distro 
supplied package (.deb, .rpm, etc) or an already built HPLIP supplied tarball 
has the proper  
dependencies installed to successfully run. 

   
3. Both compile- and run-time check mode (-b or --both) (Default): This mode 
will check both of the above cases (both compile- and run-time dependencies).   
  

Check types:

   
a. EXTERNALDEP - External Dependencies  

   
b. GENERALDEP - General Dependencies (required both at compile and run time)

   
c. COMPILEDEP - Compile time Dependencies   

   
d. [All are run-time checks]

   
PYEXT SCANCONF QUEUES PERMISSION

   

Status Types:
OK
MISSING   - Missing Dependency or Permission or Plug-in
INCOMPAT  - Incompatible dependency-version or Plugin-version

warning: 2-9.1 version is not supported. Using 2-8.6 versions dependencies to 
verify and install...

---
| SYSTEM INFO |
---

 Kernel: 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) GNU/Linux
 Host: persic
 Proc: 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) GNU/Linux
 Distribution: 2 9.1
 Bitness: 64 bit


---
| HPLIP CONFIGURATION |
---

HPLIP-Version: HPLIP 3.16.11
HPLIP-Home: /usr/share/hplip
warning: HPLIP-Installation: Auto installation is not supported for 2 distro  
9.1 version 

Current contents of '/etc/hp/hplip.conf' file:
# hplip.conf.  Generated from hplip.conf.in by configure.

[hplip]
version=3.16.11

[dirs]
home=/usr/share/hplip
run=/var/run
ppd=/usr/share/ppd/hplip/HP
ppdbase=/usr/share/ppd/hplip
doc=/usr/share/doc/hplip
html=/usr/share/doc/hplip-doc
icon=no
cupsbackend=/usr/lib/cups/backend
cupsfilter=/usr/lib/cups/filter
drv=/usr/share/cups/drv
bin=/usr/bin
apparmor=/etc/apparmor.d
# Following values are determined at configure time and cannot be changed.
[configure]
network-build=yes
libusb01-build=no
pp-build=yes
gui-build=yes
scanner-build=yes
fax-build=yes
dbus-build=yes
cups11-b

Bug#1033616: cups prepends job number to job-name so job names near 255 characters may be too long

2023-03-28 Thread John Hughes
Package: cups
Version: 2.3.3op2-3+deb11u2
Severity: normal

Dear Maintainer,

   * What led up to the situation?

I printed a page from firefox with a very, very long URL.  Firefox used the 
first 255 bytes of the URL as the job name.

   * What was the outcome of this action?

The job mysteriously didn't print.  Lookin in the cups log (with debug on) I 
found the lines:

D [28/Mar/2023:18:14:44 +0200] [Job 365] job-name nameWithoutLanguage 365 - 
https://xxx//xx

D [28/Mar/2023:18:27:36 +0200] [Job 369] Validate-Job: 
client-error-request-value-too-long (client-error-request-value-too-long)

notice how the job name passed to cups ("https://xxx...";) is shorter than 255 
characters, but when the job number "365 - " is prepended it is longer tnan 255 
characters and so overflows.

   * What outcome did you expect instead?

That my print job be printed rather than just geting stuck in the print queue 
forever.

How to reproduce:

lp -o 
'job-name=https://xxx//xx'


-- System Information:
Debian Release: 11.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-21-amd64 (SMP w/4 CPU threads)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages cups depends on:
ii  cups-client2.3.3op2-3+deb11u2
ii  cups-common2.3.3op2-3+deb11u2
ii  cups-core-drivers  2.3.3op2-3+deb11u2
ii  cups-daemon2.3.3op2-3+deb11u2
ii  cups-filters   1.28.7-1+deb11u1
ii  cups-ppdc  2.3.3op2-3+deb11u2
ii  cups-server-common 2.3.3op2-3+deb11u2
ii  debconf [debconf-2.0]  1.5.77
ii  ghostscript9.53.3~dfsg-7+deb11u2
ii  libavahi-client3   0.8-5+deb11u1
ii  libavahi-common3   0.8-5+deb11u1
ii  libc6  2.31-13+deb11u5
ii  libcups2   2.3.3op2-3+deb11u2
ii  libgcc-s1  10.2.1-6
ii  libstdc++6 10.2.1-6
ii  libusb-1.0-0   2:1.0.24-3
ii  poppler-utils  20.09.0-3.1+deb11u1
ii  procps 2:3.3.17-5

Versions of packages cups recommends:
ii  avahi-daemon  0.8-5+deb11u1
ii  colord1.4.5-3

Versions of packages cups suggests:
ii  cups-bsd   2.3.3op2-3+deb11u2
pn  cups-pdf   
ii  foomatic-db-compressed-ppds [foomatic-db]  20200820-1
ii  smbclient  2:4.13.13+dfsg-1~deb11u5
ii  udev   247.3-7+deb11u1

-- debconf information:
  cupsys/backend: lpd, socket, usb, snmp, dnssd
  cupsys/raw-print: true