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

Fix for XRef stream parsing when last object not included #399

Merged
merged 3 commits into from
Apr 10, 2019

Conversation

gunnsth
Copy link
Contributor

@gunnsth gunnsth commented Apr 2, 2019

Some PDF files using an XRef stream for cross-references have been encountered that don't specify the last object (in Index) and the last object is referring to the actual XRef stream itself.

The fix is twofold:

  1. If the Index is missing coverage of the last object, instead of appending objNum+1, we append the maximumIndex+1 where maximumIndex is the maximum object number encountered prior to that object.
  2. When we encounter an object in the table with an offset equal to where the XRef stream was parsed, then automatically correct the object number.

Test included which covers this case.

Instead of appending the number of objects appends higher than the maximum index.
@gunnsth gunnsth added this to the v3.0.0-rc.1 milestone Apr 2, 2019
@codecov
Copy link

codecov bot commented Apr 2, 2019

Codecov Report

Merging #399 into v3 will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##              v3     #399      +/-   ##
=========================================
+ Coverage   60.8%   60.89%   +0.08%     
=========================================
  Files        151      151              
  Lines      27493    27502       +9     
=========================================
+ Hits       16716    16746      +30     
+ Misses     10374    10371       -3     
+ Partials     403      385      -18
Impacted Files Coverage Δ
pdf/core/parser.go 76.09% <100%> (+0.62%) ⬆️
pdf/creator/styled_paragraph.go 93.57% <0%> (+3.33%) ⬆️
pdf/creator/utils.go 82.14% <0%> (+10.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8001422...8a647e9. Read the comment docs.

@gunnsth gunnsth requested a review from adrg April 9, 2019 09:07
Copy link
Collaborator

@adrg adrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@gunnsth gunnsth merged commit ea91b30 into v3 Apr 10, 2019
@gunnsth gunnsth deleted the v3-crossrefs-parse-fixes branch April 10, 2019 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants