From 2bfa78540c375916ec9973f0ae11271b098180bd Mon Sep 17 00:00:00 2001 From: Artem Strygin Date: Mon, 23 Jul 2018 19:54:34 +0000 Subject: Rework of CPDF_Object writing. Move writing logic into implementation of related clases. Change-Id: If70dc418b352b562ee681ea34fa6595d6f52eee3 Reviewed-on: https://pdfium-review.googlesource.com/36350 Commit-Queue: Art Snake Reviewed-by: Tom Sepez --- core/fpdfapi/parser/cpdf_dictionary.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi/parser/cpdf_dictionary.cpp') diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp index 78227ae70a..585930427c 100644 --- a/core/fpdfapi/parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/parser/cpdf_dictionary.cpp @@ -269,10 +269,13 @@ ByteString CPDF_Dictionary::MaybeIntern(const ByteString& str) { return m_pPool ? m_pPool->Intern(str) : str; } -bool CPDF_Dictionary::WriteTo(IFX_ArchiveStream* archive) const { +bool CPDF_Dictionary::WriteTo(IFX_ArchiveStream* archive, + const CPDF_Encryptor* encryptor) const { if (!archive->WriteString("<<")) return false; + const bool is_signature = CPDF_CryptoHandler::IsSignatureDictionary(this); + for (const auto& it : *this) { const ByteString& key = it.first; CPDF_Object* pValue = it.second.get(); @@ -280,9 +283,11 @@ bool CPDF_Dictionary::WriteTo(IFX_ArchiveStream* archive) const { !archive->WriteString(PDF_NameEncode(key).AsStringView())) { return false; } - - if (!pValue->WriteTo(archive)) + if (!pValue->WriteTo(archive, !is_signature || key != "Contents" + ? encryptor + : nullptr)) { return false; + } } return archive->WriteString(">>"); } -- cgit v1.2.3