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

Fixes unhandled fatal error when EPUB content.opf date is badly formatted. #921

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

karenhanson
Copy link
Contributor

We had an EPUB with this value in the content.opf metadata file:

      <opf:meta property="dcterms:modified">
			2012-04-12T12:00:00Z
		</opf:meta>

The EPUB module checks for a valid date. In this case, it was pulling in the whitespace around the value and creating an invalid date. This revealed that the Exception resulting from a badly formatted date would cause the report to crash without proper handling. To replicate it, you can edit the content.opf for an EPUB file and replace the date with the one above.

The reason was that the ErrorMessages.properties file was on the wrong path for the EPUB module (it was with the harvard module messages). Most error messages generated by this module are handled in EpubChecker, which is why this wasn't caught previously... but there are a few generated in JhoveRepInfoReport that are handled separately - those were not working.

To fix, I moved the ErrorMessages.properties to the correct location, and also added a trim() to remove the extra whitespace around the date value, since I don't think this should cause a failure. I did not increment any versions for this yet.

Let me know if you need anything else!

Date formatting error in the EPUB modules JhoveRepInfoReport.toDate() was causing unhandled fatal error due to incorrect location of ErrorMessages.properties.
If a content.opf date value has whitespace around it, it is labelled as invalid. This trims whitespace before checking date.
@carlwilson carlwilson added this to the JHOVE 1.32 milestone Aug 13, 2024
@carlwilson carlwilson added the bug A product defect that needs fixing label Aug 13, 2024
Copy link

codecov bot commented Aug 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.04%. Comparing base (09cd9c9) to head (9a8e7cb).
Report is 1 commits behind head on integration.

Additional details and impacted files
@@              Coverage Diff               @@
##             integration     #921   +/-   ##
==============================================
  Coverage          47.04%   47.04%           
  Complexity          1103     1103           
==============================================
  Files                 57       57           
  Lines               9087     9087           
  Branches            1625     1625           
==============================================
  Hits                4275     4275           
  Misses              4280     4280           
  Partials             532      532           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@carlwilson carlwilson merged commit 93c9fd8 into openpreserve:integration Aug 13, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A product defect that needs fixing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants