Safely exit infinite loops on AProfile.outlinesOK / checkItemOutline #704
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Other parts of the code have recursion detection, but here incorrect or mishandled escape characters can cause infinite loops. This change safely exits the loop and logs a message, similar to how things are handled in PDFModule.buildOutlineItemProperty - and it uses the same INFO message.
Proposing this change in relation to #652, #645, #646, #277, #473, #306. Regardless of how these backslash issues are fixed, there is a failure to exit the loop safely rather than crash JHOVE. I think we might need this or something similar.
I'm not sure why there is specific handling of the case when next is same as child here:
jhove/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/AProfile.java
Line 869 in 47f077f
So I left that in there. It is possible this is a prior attempt to handle infinite loops... if it is we could condense my suggestion to throw the recursion info exception when any node is revisited in outlinesOK or checkItemOutline.