ebook-viewer ignores content of script tag between <![CDATA[ and ]]>

Bug #1550966 reported by Francesco Martini on 2016-02-28
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Undecided
Unassigned

Bug Description

I'm using Calibre 2.52 on Mac OS X El Capitan v10.11.3.

If I write a script inside an xhtml file of an epub, the script is executed correctly by the ebook-viewer only if the content of the script tag isn't put inside a CDATA section and characters like "<" and "&" aren't wrote as xml/html entities. This isn't a tragedy, one can always put the script in a separate file, but this behavior is the exact opposite of other major ebook-readers that don't read correctly the epub if the CDATA section isn't specified and/or the reserved characters of xml aren't wrote as entities.

A sample page with a useless script. This version works in ebook-viewer and ADE:

<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Prova epub3</title>
        <script type="text/javascript">

        window.addEventListener('load', eventWindowLoaded, false);

        function eventWindowLoaded() {
          init();
        }
        function init() {
          for (x=0;x<3;x++) {
            var parag = document.getElementById('par');
            parag.innerHTML += "Hi ";
          }
        }

        </script>
    </head>
    <body>
        <p id="par">&#160;</p>
    </body>
</html>

This version works in ADE, iBooks, Readium and Azardi:

<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Prova epub3</title>
        <script type="text/javascript">
        <![CDATA[
        window.addEventListener('load', eventWindowLoaded, false);

        function eventWindowLoaded() {
          init();
        }
        function init() {
          for (x=0;x<3;x++) {
            var parag = document.getElementById('par');
            parag.innerHTML += "Hi ";
          }
        }
        ]]>
        </script>
    </head>
    <body>
        <p id="par">&#160;</p>
    </body>
</html>

Thanks!

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
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers