Ticket #56 (closed defect: fixed)
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: |
Description
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.