Bug 53502 - [PATCH] AFP images without a matching end-structured field ID would cause errors
Summary: [PATCH] AFP images without a matching end-structured field ID would cause errors
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: general (show other bugs)
Version: all
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-03 15:40 UTC by Robert Meyer
Modified: 2012-07-04 07:48 UTC (History)
0 users



Attachments
Code changes which now conform to the AFP specification for end structured fields (13.79 KB, patch)
2012-07-03 15:40 UTC, Robert Meyer
Details | Diff
AFP test files zip attached need to be extracted to test/java/org/apache/fop/afp/ (11.12 KB, application/x-zip-compressed)
2012-07-03 15:42 UTC, Robert Meyer
Details
Example fail test case (17.04 KB, application/x-zip-compressed)
2012-07-03 15:51 UTC, Robert Meyer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Meyer 2012-07-03 15:40:44 UTC
Created attachment 29026 [details]
Code changes which now conform to the AFP specification for end structured fields

When trying to use an AFP image without a matching end structured field ID, an error (Array index out of bounds) would occur. The MODCA specification [1] states that the end structured field is valid in the following three states:
- An end structured field has no matching end tag id. In which case it will match the last tag found
- The end tag ends with a FF FF value which, similar to no name will match any opening tag.
- A matching id on both start and end tags which is the usual case.

I have updated the code to support all three of these cases and now images are loaded successfully when generating an AFP document should one of these other two cases arise. These same rules also apply to all other structured field types and the code change will support these.

I have also added four new test cases which utilize four AFP images covering each case above including a name mismatch (which is expected to throw an exception). These will be attached to this patch shortly. Please note, as listed in the patch these *.afp test files should go in test/java/org/apache/fop/afp/ along with the AFPResourceUtilTestCase.java file changes.

I will also add a fail example to this patch to show an example of it breaking.

[1] http://www.outputlinks.com/SpecialInterest/AFPColorConsortium/mo_dca_reference.pdf
Comment 1 Robert Meyer 2012-07-03 15:42:42 UTC
Created attachment 29027 [details]
AFP test files zip attached need to be extracted to test/java/org/apache/fop/afp/
Comment 2 Robert Meyer 2012-07-03 15:51:49 UTC
Created attachment 29028 [details]
Example fail test case

Added a fail test case showing the issue. Generate AFP to see the error.
Comment 3 Mehdi Houshmand 2012-07-04 07:05:57 UTC
This has been applied to r1357110, just an FYI for future, this is a git diff. You need to provide patches as SVN diffs as Apache hasn't adopted git yet, to our constant dismay. Thanks for the work!
Comment 4 Mehdi Houshmand 2012-07-04 07:08:26 UTC
Robert, could you take a look at the commit, if you're happy with it could you close this bug. Thanks
Comment 5 Robert Meyer 2012-07-04 07:48:52 UTC
Thanks Mehdi. I have set the status to Closed / fixed. Apologies about the git diff as well. I've been swapping over to using the repository utilizing Geritt and SVN is one of the things I still need to do. I'll make sure any future patches use SVN next time. Thanks!