2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

Remove redundant parameters from QPDF_Stream::warn

This commit is contained in:
m-holger 2022-09-27 01:10:08 +01:00 committed by Jay Berkenbilt
parent 69e67b45bb
commit 3a86b893f7
2 changed files with 15 additions and 40 deletions

View File

@ -415,10 +415,7 @@ QPDF_Stream::filterable(
if (!filters_okay) { if (!filters_okay) {
QTC::TC("qpdf", "QPDF_Stream invalid filter"); QTC::TC("qpdf", "QPDF_Stream invalid filter");
warn( warn("stream filter type is not name or array");
qpdf_e_damaged_pdf,
this->offset,
"stream filter type is not name or array");
return false; return false;
} }
@ -466,11 +463,7 @@ QPDF_Stream::filterable(
// one case of a file whose /DecodeParms was [ << >> ] when // one case of a file whose /DecodeParms was [ << >> ] when
// /Filters was empty has been seen in the wild. // /Filters was empty has been seen in the wild.
if ((filters.size() != 0) && (decode_parms.size() != filters.size())) { if ((filters.size() != 0) && (decode_parms.size() != filters.size())) {
warn( warn("stream /DecodeParms length is inconsistent with filters");
qpdf_e_damaged_pdf,
this->offset,
"stream /DecodeParms length is"
" inconsistent with filters");
filterable = false; filterable = false;
} }
@ -582,9 +575,8 @@ QPDF_Stream::pipeStreamData(
} }
Pl_Flate* flate = dynamic_cast<Pl_Flate*>(pipeline); Pl_Flate* flate = dynamic_cast<Pl_Flate*>(pipeline);
if (flate != nullptr) { if (flate != nullptr) {
flate->setWarnCallback([this](char const* msg, int code) { flate->setWarnCallback(
warn(qpdf_e_damaged_pdf, this->offset, msg); [this](char const* msg, int code) { warn(msg); });
});
} }
} }
} }
@ -647,28 +639,17 @@ QPDF_Stream::pipeStreamData(
if (filter && (!suppress_warnings) && normalizer.get() && if (filter && (!suppress_warnings) && normalizer.get() &&
normalizer->anyBadTokens()) { normalizer->anyBadTokens()) {
warn( warn("content normalization encountered bad tokens");
qpdf_e_damaged_pdf,
this->offset,
"content normalization encountered bad tokens");
if (normalizer->lastTokenWasBad()) { if (normalizer->lastTokenWasBad()) {
QTC::TC("qpdf", "QPDF_Stream bad token at end during normalize"); QTC::TC("qpdf", "QPDF_Stream bad token at end during normalize");
warn( warn("normalized content ended with a bad token; you may be able "
qpdf_e_damaged_pdf, "to resolve this by coalescing content streams in combination "
this->offset, "with normalizing content. From the command line, specify "
"normalized content ended with a bad token;" "--coalesce-contents");
" you may be able to resolve this by"
" coalescing content streams in combination"
" with normalizing content. From the command"
" line, specify --coalesce-contents");
} }
warn( warn("Resulting stream data may be corrupted but is may still useful "
qpdf_e_damaged_pdf, "for manual inspection. For more information on this warning, "
this->offset, "search for content normalization in the manual.");
"Resulting stream data may be corrupted but is"
" may still useful for manual inspection."
" For more information on this warning, search"
" for content normalization in the manual.");
} }
return success; return success;
@ -733,10 +714,7 @@ QPDF_Stream::replaceDict(QPDFObjectHandle const& new_dict)
} }
void void
QPDF_Stream::warn( QPDF_Stream::warn(std::string const& message)
qpdf_error_code_e error_code,
qpdf_offset_t offset,
std::string const& message)
{ {
this->qpdf->warn(error_code, "", offset, message); this->qpdf->warn(qpdf_e_damaged_pdf, "", this->offset, message);
} }

View File

@ -98,10 +98,7 @@ class QPDF_Stream: public QPDFValue
std::vector<std::shared_ptr<QPDFStreamFilter>>& filters, std::vector<std::shared_ptr<QPDFStreamFilter>>& filters,
bool& specialized_compression, bool& specialized_compression,
bool& lossy_compression); bool& lossy_compression);
void warn( void warn(std::string const& message);
qpdf_error_code_e error_code,
qpdf_offset_t offset,
std::string const& message);
void setDictDescription(); void setDictDescription();
bool filter_on_write; bool filter_on_write;