Remove broken QPDFTokenizer::expectInlineImage

This commit is contained in:
Jay Berkenbilt 2019-06-21 18:49:09 -04:00
parent 25dd3c6750
commit 45dac410b5
8 changed files with 13 additions and 2391 deletions

View File

@ -4,6 +4,10 @@
QPDF::copyForeignObject with an unused boolean parameter. If you
were, for some reason, calling this, just take the parameter away.
* Source-level incompatibility: remove the version
QPDF::copyForeignObject with an unused boolean parameter. If you
were, for some reason, calling this, just take the parameter away.
* Source-level incompatibility: rename QUtil::strcasecmp to
QUtil::str_compare_nocase. This is a non-compatible change, but
QUtil::strcasecmp is hardly the most important part of qpdf's API.

3
TODO
View File

@ -1,9 +1,6 @@
Next ABI
========
* Remove version of QPDFTokenizer::expectInlineImage with no
arguments.
* Build with -fvisibility=hidden by default. Fix QPDF_DLL. See #302
for discussion. See also https://gcc.gnu.org/wiki/Visibility

View File

@ -190,12 +190,6 @@ class QPDFTokenizer
QPDF_DLL
void expectInlineImage(PointerHolder<InputSource> input);
// Legacy version. New code should not call this. The token
// returned will include the EI keyword. The recipient of the
// token will have to remove it.
QPDF_DLL
void expectInlineImage();
private:
// Do not implement copy or assignment
QPDFTokenizer(QPDFTokenizer const&);

View File

@ -542,20 +542,6 @@ QPDFTokenizer::presentCharacter(char ch)
this->m->inline_image_bytes = 0;
this->m->state = st_token_ready;
}
else if ((this->m->inline_image_bytes == 0) &&
(len >= 4) &&
isDelimiter(this->m->val.at(len-4)) &&
(this->m->val.at(len-3) == 'E') &&
(this->m->val.at(len-2) == 'I') &&
isDelimiter(this->m->val.at(len-1)))
{
QTC::TC("qpdf", "QPDFTokenizer found EI the old way");
this->m->val.erase(len - 1);
this->m->type = tt_inline_image;
this->m->unread_char = true;
this->m->char_to_unread = ch;
this->m->state = st_token_ready;
}
}
else
{
@ -628,20 +614,6 @@ QPDFTokenizer::presentCharacter(char ch)
void
QPDFTokenizer::presentEOF()
{
if (this->m->state == st_inline_image)
{
size_t len = this->m->val.length();
if ((len >= 3) &&
isDelimiter(this->m->val.at(len-3)) &&
(this->m->val.at(len-2) == 'E') &&
(this->m->val.at(len-1) == 'I'))
{
QTC::TC("qpdf", "QPDFTokenizer inline image at EOF the old way");
this->m->type = tt_inline_image;
this->m->state = st_token_ready;
}
}
if (this->m->state == st_literal)
{
QTC::TC("qpdf", "QPDFTokenizer EOF reading appendable token");
@ -669,12 +641,6 @@ QPDFTokenizer::presentEOF()
this->m->state = st_token_ready;
}
void
QPDFTokenizer::expectInlineImage()
{
expectInlineImage(PointerHolder<InputSource>());
}
void
QPDFTokenizer::expectInlineImage(PointerHolder<InputSource> input)
{

View File

@ -431,9 +431,7 @@ qpdf from_nr from repeat_nr 0
QPDF resolve duplicated page object 0
QPDF handle direct page object 0
QPDFTokenizer finder found wrong word 0
QPDFTokenizer found EI the old way 0
QPDFTokenizer found EI by byte count 0
QPDFTokenizer inline image at EOF the old way 0
QPDFTokenizer found EI after more than one try 0
QPDFPageObjectHelper externalize inline image 0
QPDFPageObjectHelper keep inline image 0

View File

@ -796,7 +796,7 @@ foreach my $d (@eii_tests)
show_ntests();
# ----------
$td->notify("--- Tokenizer ---");
$n_tests += 5;
$n_tests += 4;
$td->runtest("tokenizer with no ignorable",
{$td->COMMAND => "test_tokenizer -no-ignorable tokens.pdf"},
@ -808,11 +808,6 @@ $td->runtest("tokenizer",
{$td->FILE => "tokens.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("tokenizer with old inline image code",
{$td->COMMAND => "test_tokenizer -old-ei tokens.pdf"},
{$td->FILE => "tokens-old-ei.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("tokenizer with max_len",
{$td->COMMAND => "test_tokenizer -maxlen 50 tokens.pdf"},
{$td->FILE => "tokens-maxlen.out", $td->EXIT_STATUS => 0},

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami
<< " [-maxlen len | -no-ignorable | -old-ei] filename"
<< " [-maxlen len | -no-ignorable] filename"
<< std::endl;
exit(2);
}
@ -133,7 +133,7 @@ try_skipping(QPDFTokenizer& tokenizer, PointerHolder<InputSource> is,
static void
dump_tokens(PointerHolder<InputSource> is, std::string const& label,
size_t max_len, bool include_ignorable,
bool skip_streams, bool skip_inline_images, bool old_ei)
bool skip_streams, bool skip_inline_images)
{
Finder f1(is, "endstream");
std::cout << "--- BEGIN " << label << " ---" << std::endl;
@ -186,14 +186,7 @@ dump_tokens(PointerHolder<InputSource> is, std::string const& label,
{
char ch;
is->read(&ch, 1);
if (old_ei)
{
tokenizer.expectInlineImage();
}
else
{
tokenizer.expectInlineImage(is);
}
tokenizer.expectInlineImage(is);
inline_image_offset = is->tell();
}
else if (token.getType() == QPDFTokenizer::tt_eof)
@ -205,7 +198,7 @@ dump_tokens(PointerHolder<InputSource> is, std::string const& label,
}
static void process(char const* filename, bool include_ignorable,
size_t max_len, bool old_ei)
size_t max_len)
{
PointerHolder<InputSource> is;
@ -213,7 +206,7 @@ static void process(char const* filename, bool include_ignorable,
FileInputSource* fis = new FileInputSource();
fis->setFilename(filename);
is = fis;
dump_tokens(is, "FILE", max_len, include_ignorable, true, false, false);
dump_tokens(is, "FILE", max_len, include_ignorable, true, false);
// Tokenize content streams, skipping inline images
QPDF qpdf;
@ -232,7 +225,7 @@ static void process(char const* filename, bool include_ignorable,
"content data", content_data.getPointer());
is = bis;
dump_tokens(is, "PAGE " + QUtil::int_to_string(pageno),
max_len, include_ignorable, false, true, old_ei);
max_len, include_ignorable, false, true);
}
// Tokenize object streams
@ -251,7 +244,7 @@ static void process(char const* filename, bool include_ignorable,
is = bis;
dump_tokens(is, "OBJECT STREAM " +
QUtil::int_to_string((*iter).getObjectID()),
max_len, include_ignorable, false, false, false);
max_len, include_ignorable, false, false);
}
}
}
@ -276,7 +269,6 @@ int main(int argc, char* argv[])
char const* filename = 0;
size_t max_len = 0;
bool include_ignorable = true;
bool old_ei = false;
for (int i = 1; i < argc; ++i)
{
if (argv[i][0] == '-')
@ -293,10 +285,6 @@ int main(int argc, char* argv[])
{
include_ignorable = false;
}
else if (strcmp(argv[i], "-old-ei") == 0)
{
old_ei = true;
}
else
{
usage();
@ -318,7 +306,7 @@ int main(int argc, char* argv[])
try
{
process(filename, include_ignorable, max_len, old_ei);
process(filename, include_ignorable, max_len);
}
catch (std::exception& e)
{