Jason Harrop created FOP-3350:
---------------------------------
Summary: PDFPageLabels.addPageLabel throws
StringIndexOutOfBoundsException for a page label of "0"
Key: FOP-3350
URL: https://issues.apache.org/jira/browse/FOP-3350
Project: FOP
Issue Type: Bug
Components: renderer/pdf
Affects Versions: main, 2.11
Reporter: Jason Harrop
addPageLabel counts a decimal label's leading zeros with
{code:java}
do {
zeroPadding++;
} while (pageLabel.charAt(zeroPadding) == '0');
{code}
which runs past the end of a label made only of zeros. A page numbered 0 is
reachable wherever a page sequence's numbering yields 0: an extension, or a
user agent that honours initial-page-number="0", as documents converted from
word processors ask for a cover page.
h3. Fix
Write an all-zero decimal label as a prefix label (/P), since /St must be at
least 1 (ISO 32000-1, 12.4.2), and so skip the loop for it. Test:
PDFPageLabelsTestCase.testPageNumberedZero labels "0", "1", "2" as {{\[0 << /P
(0) >> 1 << /S /D >>\]}}; without the fix it throws.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)