Ticket #56 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

UTF-8 encoded characters in filenames cause infinite print loop

Reported by: sle Owned by: jerome
Priority: critical Milestone:
Component: pykota Version: development
Keywords: utf8 encoding Cc:


Print jobs with filenames that contain UTF-8 encoded characters cause PyKota to start an infinite print loop:

E [17/Mar/2010:15:42:54 -0700] [Job 4178] PyKota v1.27alpha8_unofficial
E [17/Mar/2010:15:42:54 -0700] [Job 4178] cupspykota backend failed
E [17/Mar/2010:15:42:54 -0700] [Job 4178] Traceback (most recent call last):
E [17/Mar/2010:15:42:54 -0700] [Job 4178] File "/usr/lib/cups/backend/cupspykota", line 1344, in <module>
E [17/Mar/2010:15:42:54 -0700] [Job 4178] retcode = wrapper.mainWork()
E [17/Mar/2010:15:42:54 -0700] [Job 4178] File "/usr/lib/cups/backend/cupspykota", line 1011, in mainWork
E [17/Mar/2010:15:42:54 -0700] [Job 4178] return self.doWork()
E [17/Mar/2010:15:42:54 -0700] [Job 4178] File "/usr/lib/cups/backend/cupspykota", line 1189, in doWork
E [17/Mar/2010:15:42:54 -0700] [Job 4178] self.softwareJobSize, self.softwareJobPrice)
E [17/Mar/2010:15:42:54 -0700] [Job 4178] File "/usr/lib/python2.5/site-packages/pykota/storage.py", line 190, in addJobToHistory
E [17/Mar/2010:15:42:54 -0700] [Job 4178] self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, clienthost, jobsizebytes, jobmd5sum, jobpages, j
obbilling, precomputedsize, precomputedprice)
E [17/Mar/2010:15:42:54 -0700] [Job 4178] File "/usr/lib/python2.5/site-packages/pykota/storages/sql.py", line 758, in writeJobNew
D [17/Mar/2010:15:42:54 -0700] Discarding unused printer-state-changed event...
E [17/Mar/2010:15:42:54 -0700] [Job 4178] self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, hostname, jobsizebytes, md
5sum, pages, billingcode, precomputedjobsize, precomputedjobprice) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), s
elf.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), s
elf.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(jobmd5sum), self.doQuote(jobpages), self.doQuote(jobbilling), self.doQuote(precomputedsize), self.doQuote(precomputedprice)))
E [17/Mar/2010:15:42:54 -0700] [Job 4178] File "/usr/lib/python2.5/site-packages/pykota/storages/sqlitestorage.py", line 110, in doModify
E [17/Mar/2010:15:42:54 -0700] [Job 4178] self.querydebug("QUERY : %s" % query)
D [17/Mar/2010:15:42:54 -0700] Discarding unused printer-state-changed event...
E [17/Mar/2010:15:42:54 -0700] [Job 4178] File "/usr/lib/python2.5/site-packages/pykota/storage.py", line 572, in querydebug
E [17/Mar/2010:15:42:54 -0700] [Job 4178] self.tool.logdebug(qmsg.decode("UTF-8", "replace"))
E [17/Mar/2010:15:42:54 -0700] [Job 4178] File "/usr/lib/python2.5/encodings/utf_8.py", line 16, in decode
E [17/Mar/2010:15:42:54 -0700] [Job 4178] return codecs.utf_8_decode(input, errors, True)
E [17/Mar/2010:15:42:54 -0700] [Job 4178] UnicodeEncodeError?: 'ascii' codec can't encode character u'\u201c' in position 349: ordinal not in range(128)
D [17/Mar/2010:15:42:54 -0700] Discarding unused printer-state-changed event...
E [17/Mar/2010:15:42:54 -0700] PID 10102 (/usr/lib/cups/backend/cupspykota) stopped with status 1!
D [17/Mar/2010:15:42:54 -0700] [Job 4178] File 0 is complete.
I [17/Mar/2010:15:42:54 -0700] [Job 4178] Backend returned status 1 (failed)

It appears that PyKota fails to insert an entry into the page log table of the accounting database because it can't handle the character encoding. This causes the accounting backend to return a failure, even though the print job itself is successful. Interpreting the failure as a problem with the whole print job, PyKota attempts the print job again, starting an infinite printing loop.

We are using a very recent snapshot of PyKota from the development tree, and we are using SQLite as our database backend.

Change History

Changed 12 years ago by jerome

  • status changed from new to closed
  • resolution set to fixed

(In [3528]) Fixes #56.

Changed 12 years ago by jerome

(In [3532]) Backported changes from [3531] to LDAP. Fixes #56 for good. References #60.

Changed 12 years ago by jerome

(In [3533]) Fixes #61. References #56, #60.

Changed 12 years ago by jerome

(In [3541]) I've finally killed this one (exactly the sort of thing I've said for
several years wrt such charset encoding problems) ! The problem was not
in the encoding of the title attribute of the job, which was perfectly
correct, but in the jobid attribute, which was still in unicode instead
of in UTF-8. This particular situation made the query string be
transformed to unicode, and an utf-8 encoded title couldn't be inserted
into it, making PyKota fail miserably.
Fixes #56. References #60, #61.

Note: See TracTickets for help on using tickets.