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

Epub2NcxException/Epub3NavException exceptions are thrown when OPF and navigation files are located in different subdirectories #91

Closed
majora2007 opened this issue May 16, 2023 · 7 comments · Fixed by #92
Assignees
Labels
Milestone

Comments

@majora2007
Copy link

I'm getting the following exception on book.GetNavigationAsync()

VersOne.Epub.Epub3NavException: Incorrect EPUB 3 navigation document: target for anchor href "titlepage.xhtml" not found in EPUB manifest.
   at VersOne.Epub.Internal.NavigationReader.GetNavigationItems(EpubSchema epubSchema, EpubContentRef epubContentRef, Epub3NavOl epub3NavOl, String epub3NavigationBaseDirectoryPath)
   at VersOne.Epub.Internal.NavigationReader.GetNavigationItems(EpubSchema epubSchema, EpubContentRef epubContentRef, Epub3Nav epub3Nav, String epub3NavDocumentFilePath)
   at VersOne.Epub.Internal.NavigationReader.GetNavigationItems(EpubSchema epubSchema, EpubContentRef epubContentRef, Epub3NavDocument epub3NavDocument)
   at VersOne.Epub.Internal.NavigationReader.GetNavigationItems(EpubSchema epubSchema, EpubContentRef epubContentRef)
   at VersOne.Epub.EpubBookRef.<GetNavigationAsync>b__32_0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at VersOne.Epub.EpubBookRef.GetNavigationAsync()
   at API.Services.BookService.GenerateTableOfContents(Chapter chapter) in C:\Users\josep\Documents\Projects\KavitaOrg\Kavita\API\Services\BookService.cs:line 914

I can confirm this book was working correctly in the previous version.

here are some parts of the epub. (I can send it to you outside of Github, you can contact me by grabbing my email from my git signature)

<item id="titlepage" href="Text/titlepage.xhtml" media-type="application/xhtml+xml" properties="svg calibre:title-page"/>
    <item id="toc.xhtml" href="Text/toc.xhtml" media-type="application/xhtml+xml" properties="nav"/>
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
  <head>
    <meta name="dtb:uid" content="9781718349490"/>
    <meta name="dtb:depth" content="1"/>
    <meta name="dtb:totalPageCount" content="0"/>
    <meta name="dtb:maxPageNumber" content="0"/>
  </head>
<docTitle>
  <text>Peddler in Another World: I Can Go Back to My World Whenever I Want! Volume 1</text>
</docTitle>
<navMap>
  <navPoint id="navPoint1">
    <navLabel>
      <text>Cover</text>
    </navLabel>
    <content src="Text/titlepage.xhtml"/>
  </navPoint>

root/OEBPS/content.opf,
root/OEBPS/toc.ncx
root/OEBPS/Text/all xhtml here

@vers-one vers-one self-assigned this May 16, 2023
@vers-one
Copy link
Owner

Reproduced. Working on the fix.

@vers-one vers-one added the bug label May 16, 2023
@vers-one
Copy link
Owner

Turns out, this issue was present in EpubReader from its first release. Version 3.3.0 just added a sanity check which exposed this bug while previous versions were silently skipping all affected navigation items.

@vers-one vers-one changed the title v3.3.0 Causing issues with GetNavitagationAsync() Epub2NcxException/Epub3NavException exceptions are thrown when OPF and navigation files are located in different subdirectories May 17, 2023
@vers-one vers-one added this to the 3.3.1 milestone May 17, 2023
@vers-one vers-one linked a pull request May 17, 2023 that will close this issue
2 tasks
@majora2007
Copy link
Author

Ahh interesting, I'm open to allowing silently failing if I pass a parameter in. In my code, I have validation checks as well.

@vers-one
Copy link
Owner

I'll publish a proper fix tomorrow.

@vers-one
Copy link
Owner

Fixed in version 3.3.1. Thank you for reporting this issue!

@majora2007
Copy link
Author

Thanks, btw, your release notes are wrong:
EpubBook.Content.xxx.Local.ContainsKey(key) → EpubBook.Content.xxx.ContainsLocalFileWithKey(key);

should be:
EpubBook.Content.xxx.Local.ContainsKey(key) → EpubBook.Content.xxx.ContainsLocalFileRefWithKey(key);

@vers-one
Copy link
Owner

Ah, sorry, it's ContainsLocalFileWithKey for EpubBook.Content and ContainsLocalFileRefWithKey for EpubBookRef.Content. I updated the release notes to clarify this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants