mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-02 11:58:25 +00:00
Find xref without PCRE
This commit is contained in:
parent
90840be594
commit
3082e4e606
@ -477,15 +477,21 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
|
|||||||
// The PDF spec says xref must be followed by a line
|
// The PDF spec says xref must be followed by a line
|
||||||
// terminator, but files exist in the wild where it is
|
// terminator, but files exist in the wild where it is
|
||||||
// terminated by arbitrary whitespace.
|
// terminated by arbitrary whitespace.
|
||||||
PCRE xref_re("^xref\\s+");
|
if ((strncmp(buf, "xref", 4) == 0) &&
|
||||||
PCRE::Match m = xref_re.match(buf);
|
QUtil::is_space(buf[4]))
|
||||||
if (m)
|
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDF xref space",
|
QTC::TC("qpdf", "QPDF xref space",
|
||||||
((buf[4] == '\n') ? 0 :
|
((buf[4] == '\n') ? 0 :
|
||||||
(buf[4] == '\r') ? 1 :
|
(buf[4] == '\r') ? 1 :
|
||||||
(buf[4] == ' ') ? 2 : 9999));
|
(buf[4] == ' ') ? 2 : 9999));
|
||||||
xref_offset = read_xrefTable(xref_offset + m.getMatch(0).length());
|
int skip = 4;
|
||||||
|
// buf is null-terminated, and QUtil::is_space('\0') is
|
||||||
|
// false, so this won't overrun.
|
||||||
|
while (QUtil::is_space(buf[skip]))
|
||||||
|
{
|
||||||
|
++skip;
|
||||||
|
}
|
||||||
|
xref_offset = read_xrefTable(xref_offset + skip);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -511,13 +511,13 @@ QUtil::srandom(unsigned int seed)
|
|||||||
bool
|
bool
|
||||||
QUtil::is_hex_digit(char ch)
|
QUtil::is_hex_digit(char ch)
|
||||||
{
|
{
|
||||||
return (strchr("0123456789abcdefABCDEF", ch) != 0);
|
return (ch && (strchr("0123456789abcdefABCDEF", ch) != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
QUtil::is_space(char ch)
|
QUtil::is_space(char ch)
|
||||||
{
|
{
|
||||||
return (strchr(" \f\n\r\t\v", ch) != 0);
|
return (ch && (strchr(" \f\n\r\t\v", ch) != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -10,7 +10,7 @@ WARNING: issue-101.pdf (trailer, file position 2026): /Length key in stream dict
|
|||||||
WARNING: issue-101.pdf (trailer, file position 2097): attempting to recover stream length
|
WARNING: issue-101.pdf (trailer, file position 2097): attempting to recover stream length
|
||||||
WARNING: issue-101.pdf (trailer, file position 2097): recovered stream length: 709
|
WARNING: issue-101.pdf (trailer, file position 2097): recovered stream length: 709
|
||||||
WARNING: issue-101.pdf (trailer, file position 2928): unknown token while reading object; treating as string
|
WARNING: issue-101.pdf (trailer, file position 2928): unknown token while reading object; treating as string
|
||||||
WARNING: issue-101.pdf (trailer, file position 2930): unknown token while reading object; treating as string
|
WARNING: issue-101.pdf (trailer, file position 2929): unknown token while reading object; treating as string
|
||||||
WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake1
|
WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake1
|
||||||
WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake2
|
WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake2
|
||||||
WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake3
|
WARNING: issue-101.pdf (trailer, file position 2928): expected dictionary key but found non-name object; inserting key /QPDFFake3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user