Commit fb77eab
Account for inaccurate offsets in getXrefData() (#692)
* Account for inaccurate offsets in getXrefData()
Normally offset pointers to `xref` keywords in a PDF document are exact to the byte. However, in some cases the pointer may point to some whitespace *before* the `xref` keyword. Adobe Acrobat takes these 'errors' in stride, displaying the document anyway, and so should PdfParser.
Clean up the getXrefData() function in **RawDataParser.php**. It now only needs to do one `preg_match_all()` and pushes the caret past whitespace when looking for `xref` keywords.
Use existing **Issue557.pdf** to create a new file: **Issue673.pdf** where the last `/Prev 13486` command has been decremented to `/Prev 13485`. Trying to parse this file would cause an Exception without this fix.
* Drop unnecessary PREG_OFFSET_CAPTURE
No need to use `PREG_OFFSET_CAPTURE` here.
---------
Co-authored-by: Konrad Abicht <hi@inspirito.de>1 parent ed3fc0b commit fb77eab
3 files changed
Lines changed: 48 additions & 26 deletions
File tree
- samples/bugs
- src/Smalot/PdfParser/RawData
- tests/PHPUnit/Integration/RawData
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
867 | | - | |
868 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
869 | 879 | | |
870 | | - | |
871 | | - | |
| 880 | + | |
| 881 | + | |
872 | 882 | | |
873 | 883 | | |
874 | 884 | | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
890 | 892 | | |
891 | | - | |
892 | | - | |
| 893 | + | |
| 894 | + | |
893 | 895 | | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
| 896 | + | |
898 | 897 | | |
899 | | - | |
| 898 | + | |
| 899 | + | |
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
175 | 197 | | |
0 commit comments