diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index cab82c7..3a96465 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -231,7 +231,7 @@ QPDF::closeInputSource() void QPDF::setPasswordIsHexKey(bool val) { - m->cf.provided_password_is_hex_key(val); + m->cf.password_is_hex_key(val); } void @@ -250,7 +250,7 @@ QPDF::registerStreamFilter( void QPDF::setIgnoreXRefStreams(bool val) { - m->cf.ignore_xref_streams(val); + (void)m->cf.ignore_xref_streams(val); } std::shared_ptr @@ -275,19 +275,19 @@ QPDF::setOutputStreams(std::ostream* out, std::ostream* err) void QPDF::setSuppressWarnings(bool val) { - m->cf.suppress_warnings(val); + (void)m->cf.suppress_warnings(val); } void QPDF::setMaxWarnings(size_t val) { - m->cf.max_warnings(val); + (void)m->cf.max_warnings(val); } void QPDF::setAttemptRecovery(bool val) { - (void)m->cf.attempt_recovery(val); + (void)m->cf.surpress_recovery(!val); } void diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index 41f701e..d920ab0 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -1739,7 +1739,7 @@ QPDFJob::doProcess( // was incorrectly encoded, there's a good chance we'd succeed here. std::string ptemp; - if (password && !m->qcf.provided_password_is_hex_key()) { + if (password && !m->qcf.password_is_hex_key()) { if (m->password_mode == QPDFJob::pm_hex_bytes) { // Special case: handle --password-mode=hex-bytes for input password as well as output // password @@ -1747,8 +1747,7 @@ QPDFJob::doProcess( password = ptemp.c_str(); } } - if (!password || empty || m->qcf.provided_password_is_hex_key() || - m->suppress_password_recovery) { + if (!password || empty || m->qcf.password_is_hex_key() || m->suppress_password_recovery) { // There is no password, or we're not doing recovery, so just do the normal processing with // the supplied password. doProcessOnce(pdf, fn, password, empty, used_for_input, main_input); diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc index 667bac8..de8c0a6 100644 --- a/libqpdf/QPDFJob_config.cc +++ b/libqpdf/QPDFJob_config.cc @@ -466,7 +466,7 @@ QPDFJob::Config::password(std::string const& parameter) QPDFJob::Config* QPDFJob::Config::passwordIsHexKey() { - o.m->qcf.provided_password_is_hex_key(true); + o.m->qcf.password_is_hex_key(true); return this; } @@ -663,7 +663,7 @@ QPDFJob::Config::suppressPasswordRecovery() QPDFJob::Config* QPDFJob::Config::suppressRecovery() { - o.m->qcf.attempt_recovery(false); + o.m->qcf.surpress_recovery(true); return this; } diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc index 6998698..5a0f2c0 100644 --- a/libqpdf/QPDF_encryption.cc +++ b/libqpdf/QPDF_encryption.cc @@ -904,7 +904,7 @@ QPDF::EncryptionParameters::initialize(QPDF& qpdf) } Encryption data(V, R, Length / 8, p, O, U, OE, UE, Perms, id1, encrypt_metadata); - if (qm.cf.provided_password_is_hex_key()) { + if (qm.cf.password_is_hex_key()) { // ignore passwords in file encryption_key = QUtil::hex_decode(provided_password); return; diff --git a/libqpdf/QPDF_objects.cc b/libqpdf/QPDF_objects.cc index 5960e9c..a9e8b27 100644 --- a/libqpdf/QPDF_objects.cc +++ b/libqpdf/QPDF_objects.cc @@ -157,7 +157,7 @@ Objects::parse(char const* password) throw damagedPDF("", -1, std::string("error reading xref: ") + e.what()); } } catch (QPDFExc& e) { - if (cf.attempt_recovery()) { + if (!cf.surpress_recovery()) { reconstruct_xref(e, xref_offset > 0); } else { throw; @@ -1248,7 +1248,7 @@ Objects::readStream(QPDFObjectHandle& object, QPDFObjGen og, qpdf_offset_t offse throw damagedPDF("expected endstream"); } } catch (QPDFExc& e) { - if (cf.attempt_recovery()) { + if (!cf.surpress_recovery()) { warn(e); length = recoverStreamLength(m->file, og, stream_offset); } else { @@ -1431,7 +1431,7 @@ Objects::readObjectAtOffset( QPDFObjGen og; setLastObjectDescription(description, exp_og); - if (!cf.attempt_recovery()) { + if (cf.surpress_recovery()) { try_recovery = false; } diff --git a/libqpdf/qpdf/QPDF_private.hh b/libqpdf/qpdf/QPDF_private.hh index 98e0f81..7ab1657 100644 --- a/libqpdf/qpdf/QPDF_private.hh +++ b/libqpdf/qpdf/QPDF_private.hh @@ -34,15 +34,15 @@ namespace qpdf } bool - provided_password_is_hex_key() const + password_is_hex_key() const { - return provided_password_is_hex_key_; + return password_is_hex_key_; } Config& - provided_password_is_hex_key(bool val) + password_is_hex_key(bool val) { - provided_password_is_hex_key_ = val; + password_is_hex_key_ = val; return *this; } @@ -99,15 +99,15 @@ namespace qpdf } bool - attempt_recovery() const + surpress_recovery() const { - return attempt_recovery_; + return surpress_recovery_; } Config& - attempt_recovery(bool val) + surpress_recovery(bool val) { - attempt_recovery_ = val; + surpress_recovery_ = val; return *this; } @@ -142,10 +142,10 @@ namespace qpdf size_t max_warnings_{0}; - bool provided_password_is_hex_key_{false}; + bool password_is_hex_key_{false}; bool ignore_xref_streams_{false}; bool suppress_warnings_{false}; - bool attempt_recovery_{true}; + bool surpress_recovery_{false}; bool check_mode_{false}; bool immediate_copy_from_{false}; }; // Class Config