mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
Don't use handleWarning, which is being reverted
This commit is contained in:
parent
aa89476e15
commit
f68e25c7f2
@ -742,8 +742,9 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances(
|
|||||||
&this->qpdf, DA.getUTF8Value());
|
&this->qpdf, DA.getUTF8Value());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
auto nwarnings = this->qpdf.numWarnings();
|
||||||
da_stream.parseAsContents(&rf);
|
da_stream.parseAsContents(&rf);
|
||||||
if (rf.sawBad())
|
if (this->qpdf.numWarnings() > nwarnings)
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper /DA parse error");
|
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper /DA parse error");
|
||||||
}
|
}
|
||||||
@ -858,8 +859,9 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
|
|||||||
ResourceFinder rf;
|
ResourceFinder rf;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
auto nwarnings = this->qpdf.numWarnings();
|
||||||
stream.parseAsContents(&rf);
|
stream.parseAsContents(&rf);
|
||||||
if (rf.sawBad())
|
if (this->qpdf.numWarnings() > nwarnings)
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper AP parse error");
|
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper AP parse error");
|
||||||
}
|
}
|
||||||
|
@ -1949,15 +1949,10 @@ QPDFObjectHandle::parseContentStream_internal(
|
|||||||
pipeContentStreams(&buf, description, all_description);
|
pipeContentStreams(&buf, description, all_description);
|
||||||
PointerHolder<Buffer> stream_data = buf.getBuffer();
|
PointerHolder<Buffer> stream_data = buf.getBuffer();
|
||||||
callbacks->contentSize(stream_data->getSize());
|
callbacks->contentSize(stream_data->getSize());
|
||||||
QPDF* context = getOwningQPDF();
|
|
||||||
if ((! context) && isArray() && (getArrayNItems() > 0))
|
|
||||||
{
|
|
||||||
context = getArrayItem(0).getOwningQPDF();
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
parseContentStream_data(stream_data, all_description,
|
parseContentStream_data(stream_data, all_description,
|
||||||
callbacks, context);
|
callbacks, getOwningQPDF());
|
||||||
}
|
}
|
||||||
catch (TerminateParsing&)
|
catch (TerminateParsing&)
|
||||||
{
|
{
|
||||||
|
@ -684,24 +684,28 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
|
|||||||
ResourceFinder rf;
|
ResourceFinder rf;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
auto q = ph.oh.getOwningQPDF();
|
||||||
|
size_t before_nw = (q ? q->numWarnings() : 0);
|
||||||
ph.parseContents(&rf);
|
ph.parseContents(&rf);
|
||||||
|
size_t after_nw = (q ? q->numWarnings() : 0);
|
||||||
|
if (after_nw > before_nw)
|
||||||
|
{
|
||||||
|
ph.oh.warnIfPossible(
|
||||||
|
"Bad token found while scanning content stream; "
|
||||||
|
"not attempting to remove unreferenced objects from"
|
||||||
|
" this object");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
QTC::TC("qpdf", "QPDFPageObjectHelper bad token finding names");
|
||||||
ph.oh.warnIfPossible(
|
ph.oh.warnIfPossible(
|
||||||
std::string("Unable to parse content stream: ") + e.what() +
|
std::string("Unable to parse content stream: ") + e.what() +
|
||||||
"; not attempting to remove unreferenced objects"
|
"; not attempting to remove unreferenced objects"
|
||||||
" from this object");
|
" from this object");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (rf.sawBad())
|
|
||||||
{
|
|
||||||
QTC::TC("qpdf", "QPDFPageObjectHelper bad token finding names");
|
|
||||||
ph.oh.warnIfPossible(
|
|
||||||
"Bad token found while scanning content stream; "
|
|
||||||
"not attempting to remove unreferenced objects from this object");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We will walk through /Font and /XObject dictionaries, removing
|
// We will walk through /Font and /XObject dictionaries, removing
|
||||||
// any resources that are not referenced. We must make copies of
|
// any resources that are not referenced. We must make copies of
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <qpdf/ResourceFinder.hh>
|
#include <qpdf/ResourceFinder.hh>
|
||||||
|
|
||||||
ResourceFinder::ResourceFinder() :
|
ResourceFinder::ResourceFinder() :
|
||||||
last_name_offset(0),
|
last_name_offset(0)
|
||||||
saw_bad(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,9 +44,8 @@ ResourceFinder::handleObject(QPDFObjectHandle obj, size_t offset, size_t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ResourceFinder::handleWarning()
|
ResourceFinder::handleEOF()
|
||||||
{
|
{
|
||||||
this->saw_bad = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> const&
|
std::set<std::string> const&
|
||||||
@ -61,9 +59,3 @@ ResourceFinder::getNamesByResourceType() const
|
|||||||
{
|
{
|
||||||
return this->names_by_resource_type;
|
return this->names_by_resource_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
ResourceFinder::sawBad() const
|
|
||||||
{
|
|
||||||
return this->saw_bad;
|
|
||||||
}
|
|
||||||
|
@ -9,12 +9,11 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
|
|||||||
ResourceFinder();
|
ResourceFinder();
|
||||||
virtual ~ResourceFinder() = default;
|
virtual ~ResourceFinder() = default;
|
||||||
virtual void handleObject(QPDFObjectHandle, size_t, size_t) override;
|
virtual void handleObject(QPDFObjectHandle, size_t, size_t) override;
|
||||||
virtual void handleWarning() override;
|
virtual void handleEOF() override;
|
||||||
std::set<std::string> const& getNames() const;
|
std::set<std::string> const& getNames() const;
|
||||||
std::map<std::string,
|
std::map<std::string,
|
||||||
std::map<std::string,
|
std::map<std::string,
|
||||||
std::set<size_t>>> const& getNamesByResourceType() const;
|
std::set<size_t>>> const& getNamesByResourceType() const;
|
||||||
bool sawBad() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string last_name;
|
std::string last_name;
|
||||||
@ -23,7 +22,6 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
|
|||||||
std::map<std::string,
|
std::map<std::string,
|
||||||
std::map<std::string,
|
std::map<std::string,
|
||||||
std::set<size_t>>> names_by_resource_type;
|
std::set<size_t>>> names_by_resource_type;
|
||||||
bool saw_bad;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RESOURCEFINDER_HH
|
#endif // RESOURCEFINDER_HH
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
WARNING: page object 3 0 stream 5 0, stream 7 0, stream 9 0, stream 11 0 (content, offset 375): null character not allowed in name token
|
WARNING: split-tokens.pdf, object 3 0 at offset 181: Unable to parse content stream: page object 3 0 stream 5 0, stream 7 0, stream 9 0, stream 11 0 (content, offset 375): null character not allowed in name token; not attempting to remove unreferenced objects from this object
|
||||||
WARNING: split-tokens.pdf, object 3 0 at offset 181: Bad token found while scanning content stream; not attempting to remove unreferenced objects from this object
|
|
||||||
WARNING: empty PDF: content normalization encountered bad tokens
|
WARNING: empty PDF: content normalization encountered bad tokens
|
||||||
WARNING: empty PDF: normalized content ended with a bad token; you may be able to resolve this by coalescing content streams in combination with normalizing content. From the command line, specify --coalesce-contents
|
WARNING: empty PDF: normalized content ended with a bad token; you may be able to resolve this by coalescing content streams in combination with normalizing content. From the command line, specify --coalesce-contents
|
||||||
WARNING: empty PDF: 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.
|
WARNING: empty PDF: 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.
|
||||||
|
Loading…
Reference in New Issue
Block a user