Edit book / check crashes on empty inline style tag

Bug #1292841 reported by m4mmon on 2014-03-15
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description


When editing a book, if html page contains an empty style tag, check crashes.

Calibre 1.28 64-bit windows.

How to reproduce :
In edit book, edit a page and add :
<style type="text/css" />
<style type="text/css"></style>

to the head of the file. For example:

      <title>My book</title>
      <link href="stylesheet1.css" type="text/css" rel="stylesheet" />
      <style type="text/css"></style>

Now run "Check book", it will error out with this error message :

calibre, version 1.28.0
ERROR: Unhandled exception: <b>TypeError</b>:expected string or buffer

calibre 1.28 [64bit] isfrozen: True is64bit: True
Windows-7-6.1.7601-SP1 Windows ('64bit', 'WindowsPE')
('Windows', '7', '6.1.7601')
Python 2.7.5
Windows: ('7', '6.1.7601', 'SP1', 'Multiprocessor Free')
Traceback (most recent call last):
  File "site-packages\calibre\gui2\tweak_book\boss.py", line 73, in ans
  File "site-packages\calibre\gui2\tweak_book\boss.py", line 1010, in check_requested
  File "site-packages\calibre\gui2\tweak_book\check.py", line 167, in run_checks
  File "site-packages\calibre\ebooks\oeb\polish\check\main.py", line 54, in run_checks
  File "site-packages\calibre\ebooks\oeb\polish\check\parsing.py", line 315, in check_css_parsing
  File "site-packages\cssutils-0.9.10-py2.7.egg\cssutils\parse.py", line 148, in parseString
  File "site-packages\cssutils-0.9.10-py2.7.egg\cssutils\css\cssstylesheet.py", line 355, in _setCssTextWithEncodingOverride
  File "site-packages\cssutils-0.9.10-py2.7.egg\cssutils\css\cssstylesheet.py", line 303, in _setCssText
  File "site-packages\cssutils-0.9.10-py2.7.egg\cssutils\util.py", line 410, in _parse
  File "site-packages\cssutils-0.9.10-py2.7.egg\cssutils\tokenize2.py", line 123, in tokenize
TypeError: expected string or buffer

Adding a simple white space, i.e.
<style type="text/css"> </style>
and the check runs ok.

Thank you

m4mmon (m4mmon) on 2014-03-15
description: updated
m4mmon (m4mmon) on 2014-03-15
description: updated

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
m4mmon (m4mmon) wrote :

Wouah that was lightning fast. Thank you :)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers