aboutsummaryrefslogtreecommitdiffstats
path: root/include/qpdf/QUtil.hh
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-16 03:06:38 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-17 17:43:56 +0100
commite87d149918ed6ed211f733f932df3b62ab445c12 (patch)
tree40c8e30e2296a7569433387a5f047b27e505875d /include/qpdf/QUtil.hh
parent997f4ab6cbec6be5e045bc4210d315a4e0ab76d4 (diff)
downloadqpdf-e87d149918ed6ed211f733f932df3b62ab445c12.tar.zst
Add QUtil::possible_repaired_encodings
Diffstat (limited to 'include/qpdf/QUtil.hh')
-rw-r--r--include/qpdf/QUtil.hh22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh
index 5fe8e97c..02dec5ad 100644
--- a/include/qpdf/QUtil.hh
+++ b/include/qpdf/QUtil.hh
@@ -223,6 +223,28 @@ namespace QUtil
bool& is_valid_utf8,
bool& is_utf16);
+ // Try to compensate for previously incorrectly encoded strings.
+ // We want to compensate for the following errors:
+ //
+ // * The string was supposed to be UTF-8 but was one of the
+ // single-byte encodings
+ // * The string was supposed to be PDF Doc but was either UTF-8 or
+ // one of the other single-byte encodings
+ //
+ // The returned vector always contains the original string first,
+ // and then it contains what the correct string would be in the
+ // event that the original string was the result of any of the
+ // above errors.
+ //
+ // This method is useful for attempting to recover a password that
+ // may have been previously incorrectly encoded. For example, the
+ // password was supposed to be UTF-8 but the previous application
+ // used a password encoded in WinAnsi, or if the previous password
+ // was supposed to be PDFDoc but was actually given as UTF-8 or
+ // WinAnsi, this method would find the correct password.
+ QPDF_DLL
+ std::vector<std::string> possible_repaired_encodings(std::string);
+
// If secure random number generation is supported on your
// platform and qpdf was not compiled with insecure random number
// generation, this returns a cryptographically secure random