mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +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());
|
||||
try
|
||||
{
|
||||
auto nwarnings = this->qpdf.numWarnings();
|
||||
da_stream.parseAsContents(&rf);
|
||||
if (rf.sawBad())
|
||||
if (this->qpdf.numWarnings() > nwarnings)
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper /DA parse error");
|
||||
}
|
||||
@ -858,8 +859,9 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
|
||||
ResourceFinder rf;
|
||||
try
|
||||
{
|
||||
auto nwarnings = this->qpdf.numWarnings();
|
||||
stream.parseAsContents(&rf);
|
||||
if (rf.sawBad())
|
||||
if (this->qpdf.numWarnings() > nwarnings)
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper AP parse error");
|
||||
}
|
||||
|
@ -1949,15 +1949,10 @@ QPDFObjectHandle::parseContentStream_internal(
|
||||
pipeContentStreams(&buf, description, all_description);
|
||||
PointerHolder<Buffer> stream_data = buf.getBuffer();
|
||||
callbacks->contentSize(stream_data->getSize());
|
||||
QPDF* context = getOwningQPDF();
|
||||
if ((! context) && isArray() && (getArrayNItems() > 0))
|
||||
{
|
||||
context = getArrayItem(0).getOwningQPDF();
|
||||
}
|
||||
try
|
||||
{
|
||||
parseContentStream_data(stream_data, all_description,
|
||||
callbacks, context);
|
||||
callbacks, getOwningQPDF());
|
||||
}
|
||||
catch (TerminateParsing&)
|
||||
{
|
||||
|
@ -684,24 +684,28 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
|
||||
ResourceFinder rf;
|
||||
try
|
||||
{
|
||||
auto q = ph.oh.getOwningQPDF();
|
||||
size_t before_nw = (q ? q->numWarnings() : 0);
|
||||
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)
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFPageObjectHelper bad token finding names");
|
||||
ph.oh.warnIfPossible(
|
||||
std::string("Unable to parse content stream: ") + e.what() +
|
||||
"; not attempting to remove unreferenced objects"
|
||||
" from this object");
|
||||
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
|
||||
// any resources that are not referenced. We must make copies of
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include <qpdf/ResourceFinder.hh>
|
||||
|
||||
ResourceFinder::ResourceFinder() :
|
||||
last_name_offset(0),
|
||||
saw_bad(false)
|
||||
last_name_offset(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -45,9 +44,8 @@ ResourceFinder::handleObject(QPDFObjectHandle obj, size_t offset, size_t)
|
||||
}
|
||||
|
||||
void
|
||||
ResourceFinder::handleWarning()
|
||||
ResourceFinder::handleEOF()
|
||||
{
|
||||
this->saw_bad = true;
|
||||
}
|
||||
|
||||
std::set<std::string> const&
|
||||
@ -61,9 +59,3 @@ ResourceFinder::getNamesByResourceType() const
|
||||
{
|
||||
return this->names_by_resource_type;
|
||||
}
|
||||
|
||||
bool
|
||||
ResourceFinder::sawBad() const
|
||||
{
|
||||
return this->saw_bad;
|
||||
}
|
||||
|
@ -9,12 +9,11 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
|
||||
ResourceFinder();
|
||||
virtual ~ResourceFinder() = default;
|
||||
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::map<std::string,
|
||||
std::map<std::string,
|
||||
std::set<size_t>>> const& getNamesByResourceType() const;
|
||||
bool sawBad() const;
|
||||
|
||||
private:
|
||||
std::string last_name;
|
||||
@ -23,7 +22,6 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
|
||||
std::map<std::string,
|
||||
std::map<std::string,
|
||||
std::set<size_t>>> names_by_resource_type;
|
||||
bool saw_bad;
|
||||
};
|
||||
|
||||
#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: Bad token found while scanning content stream; not attempting to remove unreferenced objects from this object
|
||||
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: 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: 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