diff --git a/src/core/jbig2.js b/src/core/jbig2.js index e360ce015129bb..fd8ee748a6378b 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -865,6 +865,22 @@ function decodeTextRegion( decodingContext ); } + + let increment = 0; + if (!transposed) { + if (referenceCorner > 1) { + currentS += symbolWidth - 1; + } else { + increment = symbolWidth - 1; + } + } else if (transposed) { + if (!(referenceCorner & 1)) { + currentS += symbolHeight - 1; + } else { + increment = symbolHeight - 1; + } + } + const offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1); const offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0); let s2, t2, symbolRow; @@ -896,7 +912,6 @@ function decodeTextRegion( ); } } - currentS += symbolHeight - 1; } else { for (t2 = 0; t2 < symbolHeight; t2++) { row = bitmap[offsetT + t2]; @@ -921,7 +936,6 @@ function decodeTextRegion( ); } } - currentS += symbolWidth - 1; } i++; const deltaS = huffman @@ -930,7 +944,7 @@ function decodeTextRegion( if (deltaS === null) { break; // OOB } - currentS += deltaS + dsOffset; + currentS += increment + deltaS + dsOffset; } while (true); } return bitmap; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 0fcd8138825619..2f2f743d1ef93b 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -636,3 +636,5 @@ !bug1868759.pdf !issue17730.pdf !bug1883609.pdf +!issue17871_bottom_right.pdf +!issue17871_top_right.pdf diff --git a/test/pdfs/issue17871_bottom_right.pdf b/test/pdfs/issue17871_bottom_right.pdf new file mode 100755 index 00000000000000..89f216be28f266 Binary files /dev/null and b/test/pdfs/issue17871_bottom_right.pdf differ diff --git a/test/pdfs/issue17871_top_right.pdf b/test/pdfs/issue17871_top_right.pdf new file mode 100755 index 00000000000000..22ef5a9d48f316 Binary files /dev/null and b/test/pdfs/issue17871_top_right.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 65168819fffb4d..9460f5e8e8dc33 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -9794,5 +9794,19 @@ "rounds": 1, "link": true, "type": "other" + }, + { + "id": "issue17871_bottom_right", + "file": "pdfs/issue17871_bottom_right.pdf", + "md5": "664807166c5279224abfbf259f701958", + "rounds": 1, + "type": "eq" + }, + { + "id": "issue17871_top_right", + "file": "pdfs/issue17871_top_right.pdf", + "md5": "07d95eabf18aee0cf38f09eb7b1390ec", + "rounds": 1, + "type": "eq" } ]