Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash for ePub 3s with an empty nav table #48

Merged
merged 1 commit into from
Apr 23, 2014

Conversation

marcuswu
Copy link
Contributor

@marcuswu marcuswu commented Apr 9, 2014

We came across an ePub3 which crashed Readium and traced it back to the handling of an empty nav table. This pull request is for the fix I found to work. The ePub passes an epubcheck and the following is the contents of the nav html (I cannot share the entire ePub as it is copyrighted material):

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xml:lang="en-us" lang="en-us" xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
    <head>
        <title>Empty TOC</title>
        <meta charset="utf-8" />
    </head>
    <body>
        <nav epub:type="toc" id="toc">
            <ol>
            </ol>
        </nav>
    </body>
</html>

@danielweck
Copy link
Member

https://github.com/readium/readium-sdk/blob/develop/ePub3/ePub/package.cpp#L918
I think this was fixed in the develop branch some time ago. daniel

@marcuswu
Copy link
Contributor Author

The particular instance I was experiencing had tocNames empty and _navigation had one entry with no children. That means it passes the check at https://github.com/readium/readium-sdk/blob/develop/ePub3/ePub/package.cpp#L906 as well as passing the test at https://github.com/readium/readium-sdk/blob/develop/ePub3/ePub/package.cpp#L918, but then there are no tocNames at https://github.com/readium/readium-sdk/blob/develop/ePub3/ePub/package.cpp#L928.

The proposed change adds an additional check to prevent attempting to pull navigation items out of a tocNames identifier which does not exist.

@danielweck
Copy link
Member

Ah, thanks for the clarification!

bormind added a commit that referenced this pull request Apr 23, 2014
Fix crash for ePub 3s with an empty nav table
@bormind bormind merged commit d84f5eb into readium:master Apr 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants