vers-one / EpubReader

.NET library for reading EPUB files
https://os.vers.one/EpubReader/
The Unlicense
479 stars 105 forks source link

Nav Parsing is too strict #116

Open majora2007 opened 6 days ago

majora2007 commented 6 days ago

Description

Upon updating to v3.2.2 Epubs are now throwing this exception for MANY of my users epubs. Is there potential to have a PackageReaderOptions setting to not throw on invalid nav and just fail silently?

The reality of the situation is many people have bad epubs, publishers rarely pack them correctly. I'm in a constant battle to support broken epubs. This library is the absolute best out there, but I need some more flexibility to allow some invalid epubs.

Is this feasible for you?

VersOne.Epub.Epub3NavException: EPUB parsing error: 'nav' element in the navigation file does not contain a required 'ol' element.

Nav page:

<nav>
<div class="s30">
<a href="../Text/part0000.xhtml">Cover</a>
</div>

Sample EPUB file

I can email you an epub. Git commits signed with an email that will reach me.

EPUB specification link

Additional context

Hope you are well, still looking forward to your Audio/Media implementation :)

majora2007 commented 6 days ago

I just rolled back to v3.3.1 and experienced the same, I think it's due to my other issue I rolled out.

https://github.com/vers-one/EpubReader/issues/91

I suppose the fix here, which is valid, also means that parsing is much stricter. I think a setting to allow how to report (throw exception or silently fail) would be the best (and i can pass that responsibility to my users).

vers-one commented 5 days ago

Is it just this NAV parsing error or are the more? Could you post the list of errors you would like to be able to ignore?

majora2007 commented 5 days ago

The only other one I can think of that might be nice to ignore is when the opf points to a file that's not in the archive. This seems to be very common as well and seems fit for a silent fail. I can look up the exception after work.