diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDF.hh | 20 | ||||
-rw-r--r-- | include/qpdf/QUtil.hh | 17 |
2 files changed, 32 insertions, 5 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 13b66977..4541db64 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -910,8 +910,7 @@ class QPDF } }; - // The ParseGuard class allows QPDFObjectHandle to detect - // re-entrant parsing. + // The ParseGuard class allows QPDFParser to detect re-entrant parsing. class ParseGuard { friend class QPDFParser; @@ -933,7 +932,7 @@ class QPDF QPDF* qpdf; }; - // Pipe class is restricted to QPDF_Stream + // Pipe class is restricted to QPDF_Stream. class Pipe { friend class QPDF_Stream; @@ -961,6 +960,20 @@ class QPDF } }; + // JobSetter class is restricted to QPDFJob. + class JobSetter + { + friend class QPDFJob; + + private: + // Enable enhanced warnings for pdf file checking. + static void + setCheckMode(QPDF& qpdf, bool val) + { + qpdf.m->check_mode = val; + } + }; + // For testing only -- do not add to DLL static bool test_json_validators(); @@ -1698,6 +1711,7 @@ class QPDF bool ignore_xref_streams{false}; bool suppress_warnings{false}; bool attempt_recovery{true}; + bool check_mode{false}; std::shared_ptr<EncryptionParameters> encp; std::string pdf_version; std::map<QPDFObjGen, QPDFXRefEntry> xref_table; diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index b42fe195..4d46f630 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -223,6 +223,11 @@ namespace QUtil QPDF_DLL std::string hex_decode(std::string const&); + // Decode a single hex digit into a char in the range 0 <= char < 16. Return + // a char >= 16 if digit is not a valid hex digit. + QPDF_DLL + inline constexpr char hex_decode_char(char digit) noexcept; + // Set stdin, stdout to binary mode QPDF_DLL void binary_stdout(); @@ -550,8 +555,7 @@ namespace QUtil inline bool QUtil::is_hex_digit(char ch) { - return ('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f') || - ('A' <= ch && ch <= 'F'); + return hex_decode_char(ch) < '\20'; } inline bool @@ -603,4 +607,13 @@ QUtil::hex_encode_char(char c) '#', hexchars[static_cast<unsigned char>(c) >> 4], hexchars[c & 0x0f]}; } +inline constexpr char +QUtil::hex_decode_char(char digit) noexcept +{ + return digit <= '9' && digit >= '0' + ? char(digit - '0') + : (digit >= 'a' ? char(digit - 'a' + 10) + : (digit >= 'A' ? char(digit - 'A' + 10) : '\20')); +} + #endif // QUTIL_HH |