summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/parser/cpdf_string.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_string.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/core/fpdfapi/parser/cpdf_string.cpp b/core/fpdfapi/parser/cpdf_string.cpp
index 851442e8b4..e7f2a9dcd6 100644
--- a/core/fpdfapi/parser/cpdf_string.cpp
+++ b/core/fpdfapi/parser/cpdf_string.cpp
@@ -7,7 +7,9 @@
#include "core/fpdfapi/parser/cpdf_string.h"
#include <utility>
+#include <vector>
+#include "core/fpdfapi/edit/cpdf_encryptor.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fxcrt/fx_stream.h"
#include "third_party/base/ptr_util.h"
@@ -65,7 +67,15 @@ WideString CPDF_String::GetUnicodeText() const {
return PDF_DecodeText(m_String);
}
-bool CPDF_String::WriteTo(IFX_ArchiveStream* archive) const {
- return archive->WriteString(
- PDF_EncodeString(GetString(), IsHex()).AsStringView());
+bool CPDF_String::WriteTo(IFX_ArchiveStream* archive,
+ const CPDF_Encryptor* encryptor) const {
+ std::vector<uint8_t> encrypted_data;
+ pdfium::span<const uint8_t> data = m_String.AsRawSpan();
+ if (encryptor) {
+ encrypted_data = encryptor->Encrypt(data);
+ data = encrypted_data;
+ }
+ const ByteString content =
+ PDF_EncodeString(ByteString(data.data(), data.size()), IsHex());
+ return archive->WriteString(content.AsStringView());
}