Commit e93381de07d47269e671a1e884248bd8e354dc24
1 parent
1d6da600
In `QPDFJob` add warning for exceeded configurable limits
- Add warning with associated documentation links. - Update tests to reflect the new warning messages.
Showing
7 changed files
with
12 additions
and
1 deletions
libqpdf/QPDFJob.cc
| @@ -25,6 +25,7 @@ | @@ -25,6 +25,7 @@ | ||
| 25 | #include <qpdf/QTC.hh> | 25 | #include <qpdf/QTC.hh> |
| 26 | #include <qpdf/QUtil.hh> | 26 | #include <qpdf/QUtil.hh> |
| 27 | #include <qpdf/Util.hh> | 27 | #include <qpdf/Util.hh> |
| 28 | +#include <qpdf/global_private.hh> | ||
| 28 | 29 | ||
| 29 | #include <qpdf/auto_job_schema.hh> // JOB_SCHEMA_DATA | 30 | #include <qpdf/auto_job_schema.hh> // JOB_SCHEMA_DATA |
| 30 | 31 | ||
| @@ -485,6 +486,11 @@ QPDFJob::writeQPDF(QPDF& pdf) | @@ -485,6 +486,11 @@ QPDFJob::writeQPDF(QPDF& pdf) | ||
| 485 | *m->log->getWarn() << m->message_prefix << ": operation succeeded with warnings\n"; | 486 | *m->log->getWarn() << m->message_prefix << ": operation succeeded with warnings\n"; |
| 486 | } | 487 | } |
| 487 | } | 488 | } |
| 489 | + if (!m->d_cfg.suppress_warnings() && global::Limits::errors()) { | ||
| 490 | + *m->log->getWarn() << m->message_prefix | ||
| 491 | + << ": some configurable limits were exceeded; for more details " | ||
| 492 | + "see https://qpdf.readthedocs.io/en/stable/cli.html#global-limits\n"; | ||
| 493 | + } | ||
| 488 | if (m->report_mem_usage) { | 494 | if (m->report_mem_usage) { |
| 489 | // Call get_max_memory_usage before generating output. When debugging, it's easier if print | 495 | // Call get_max_memory_usage before generating output. When debugging, it's easier if print |
| 490 | // statements from get_max_memory_usage are not interleaved with the output. | 496 | // statements from get_max_memory_usage are not interleaved with the output. |
libqpdf/QPDFJob_json.cc
| @@ -623,7 +623,7 @@ Handlers::beginSetPageLabelsArray(JSON) | @@ -623,7 +623,7 @@ Handlers::beginSetPageLabelsArray(JSON) | ||
| 623 | void | 623 | void |
| 624 | Handlers::beginGlobal(JSON) | 624 | Handlers::beginGlobal(JSON) |
| 625 | { | 625 | { |
| 626 | - this->c_global = c_main->global(); | 626 | + c_global = c_main->global(); |
| 627 | } | 627 | } |
| 628 | 628 | ||
| 629 | void | 629 | void |
qpdf/qtest/qpdf/global1.out
| @@ -5,3 +5,4 @@ WARNING: global.pdf: Attempting to reconstruct cross-reference table | @@ -5,3 +5,4 @@ WARNING: global.pdf: Attempting to reconstruct cross-reference table | ||
| 5 | WARNING: global.pdf (trailer, offset 759): limits error(parser-max-nesting): ignoring excessively deeply nested data structure | 5 | WARNING: global.pdf (trailer, offset 759): limits error(parser-max-nesting): ignoring excessively deeply nested data structure |
| 6 | WARNING: global.pdf: unable to find trailer dictionary while recovering damaged file | 6 | WARNING: global.pdf: unable to find trailer dictionary while recovering damaged file |
| 7 | qpdf: operation succeeded with warnings; resulting file may have some problems | 7 | qpdf: operation succeeded with warnings; resulting file may have some problems |
| 8 | +qpdf: some configurable limits were exceeded; for more details see https://qpdf.readthedocs.io/en/stable/cli.html#global-limits |
qpdf/qtest/qpdf/global2.out
| @@ -6,3 +6,4 @@ WARNING: global_damaged.pdf (trailer, offset 767): unknown token while reading o | @@ -6,3 +6,4 @@ WARNING: global_damaged.pdf (trailer, offset 767): unknown token while reading o | ||
| 6 | WARNING: global_damaged.pdf (trailer, offset 767): limits error(parser-max-errors): too many errors during parsing; treating object as null | 6 | WARNING: global_damaged.pdf (trailer, offset 767): limits error(parser-max-errors): too many errors during parsing; treating object as null |
| 7 | WARNING: global_damaged.pdf: unable to find trailer dictionary while recovering damaged file | 7 | WARNING: global_damaged.pdf: unable to find trailer dictionary while recovering damaged file |
| 8 | qpdf: operation succeeded with warnings; resulting file may have some problems | 8 | qpdf: operation succeeded with warnings; resulting file may have some problems |
| 9 | +qpdf: some configurable limits were exceeded; for more details see https://qpdf.readthedocs.io/en/stable/cli.html#global-limits |
qpdf/qtest/qpdf/global3.out
| @@ -3,3 +3,4 @@ WARNING: global.pdf: file is damaged | @@ -3,3 +3,4 @@ WARNING: global.pdf: file is damaged | ||
| 3 | WARNING: global.pdf (offset 712): expected trailer dictionary | 3 | WARNING: global.pdf (offset 712): expected trailer dictionary |
| 4 | WARNING: global.pdf: Attempting to reconstruct cross-reference table | 4 | WARNING: global.pdf: Attempting to reconstruct cross-reference table |
| 5 | qpdf: operation succeeded with warnings; resulting file may have some problems | 5 | qpdf: operation succeeded with warnings; resulting file may have some problems |
| 6 | +qpdf: some configurable limits were exceeded; for more details see https://qpdf.readthedocs.io/en/stable/cli.html#global-limits |
qpdf/qtest/qpdf/global4.out
| @@ -7,3 +7,4 @@ WARNING: global_damaged.pdf (trailer, offset 770): unknown token while reading o | @@ -7,3 +7,4 @@ WARNING: global_damaged.pdf (trailer, offset 770): unknown token while reading o | ||
| 7 | WARNING: global_damaged.pdf (trailer, offset 788): limits error(parser-max-container-size-damaged): encountered errors while parsing an array or dictionary with more than 9 elements; giving up on reading object | 7 | WARNING: global_damaged.pdf (trailer, offset 788): limits error(parser-max-container-size-damaged): encountered errors while parsing an array or dictionary with more than 9 elements; giving up on reading object |
| 8 | WARNING: global_damaged.pdf: unable to find trailer dictionary while recovering damaged file | 8 | WARNING: global_damaged.pdf: unable to find trailer dictionary while recovering damaged file |
| 9 | qpdf: operation succeeded with warnings; resulting file may have some problems | 9 | qpdf: operation succeeded with warnings; resulting file may have some problems |
| 10 | +qpdf: some configurable limits were exceeded; for more details see https://qpdf.readthedocs.io/en/stable/cli.html#global-limits |
qpdf/qtest/qpdf/issue-202.out
| @@ -7,3 +7,4 @@ WARNING: issue-202.pdf (object 222 0, offset 50101): dictionary has duplicated k | @@ -7,3 +7,4 @@ WARNING: issue-202.pdf (object 222 0, offset 50101): dictionary has duplicated k | ||
| 7 | WARNING: issue-202.pdf (object 222 0, offset 50101): dictionary has duplicated key /Producer; last occurrence overrides earlier ones | 7 | WARNING: issue-202.pdf (object 222 0, offset 50101): dictionary has duplicated key /Producer; last occurrence overrides earlier ones |
| 8 | WARNING: issue-202.pdf: unable to find trailer dictionary while recovering damaged file | 8 | WARNING: issue-202.pdf: unable to find trailer dictionary while recovering damaged file |
| 9 | qpdf: operation succeeded with warnings; resulting file may have some problems | 9 | qpdf: operation succeeded with warnings; resulting file may have some problems |
| 10 | +qpdf: some configurable limits were exceeded; for more details see https://qpdf.readthedocs.io/en/stable/cli.html#global-limits |