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

Blank media type throws error (valid epub) #47

Closed
nruffilo opened this issue Jun 13, 2022 · 2 comments
Closed

Blank media type throws error (valid epub) #47

nruffilo opened this issue Jun 13, 2022 · 2 comments

Comments

@nruffilo
Copy link

I have a valid epub, but the content.OPF file contains an item with a blank media type:

Sadly I have to be able to process files that pass epub check, and this does. Below is the stack trace from the fail. Ideally this would gracefully just ignore the file. Sadly I cannot provide the file as it contains copyrighted material, but I believe just adding the the file and a blank media-type to any should produce the same issue.

Thank you!

at VersOne.Epub.Internal.PackageReader.ReadManifest(XElement manifestNode)
at VersOne.Epub.Internal.PackageReader.d__0.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at VersOne.Epub.Internal.SchemaReader.<ReadSchemaAsync>d__0.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at VersOne.Epub.EpubReader.d__10.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at VersOne.Epub.EpubReader.d__9.MoveNext()

@vers-one
Copy link
Owner

I added an option to skip invalid manifest items.

Here's how you can use it:

EpubReaderOptions options = new()
{
    PackageReaderOptions = new PackageReaderOptions()
    {
        SkipInvalidManifestItems = true
    }
};

Then you can pass the options as the second argument to one of the EpubReader's OpenBook / OpenBookAsync / ReadBook / ReadBookAsync methods.

Could you check if this solution works for you before I publish it to Nuget?

PS. Keep in mind that this solution may cause issues at a later stage if the invalid manifest item is referenced from somewhere else (e.g. if it is the cover or the table of contents).

@vers-one
Copy link
Owner

Implemented in v3.2. Here's the documentation for the new option.

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

No branches or pull requests

2 participants