OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/src/fpdfapi/fpdf_parser/cpdf_syntax_parser.h" | 7 #include "core/src/fpdfapi/fpdf_parser/cpdf_syntax_parser.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "core/include/fpdfapi/fpdf_module.h" | 11 #include "core/include/fpdfapi/fpdf_module.h" |
12 #include "core/include/fpdfapi/fpdf_parser.h" | 12 #include "core/include/fpdfapi/fpdf_objects.h" |
| 13 #include "core/include/fpdfapi/fpdf_parser_decode.h" |
13 #include "core/include/fpdfapi/ipdf_crypto_handler.h" | 14 #include "core/include/fpdfapi/ipdf_crypto_handler.h" |
14 #include "core/include/fxcrt/fx_ext.h" | 15 #include "core/include/fxcrt/fx_ext.h" |
15 #include "core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.h" | 16 #include "core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.h" |
16 #include "third_party/base/numerics/safe_math.h" | 17 #include "third_party/base/numerics/safe_math.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 struct SearchTagRecord { | 21 struct SearchTagRecord { |
21 const char* m_pTag; | 22 const char* m_pTag; |
22 FX_DWORD m_Len; | 23 FX_DWORD m_Len; |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, true); | 462 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, true); |
462 if (!pObj) | 463 if (!pObj) |
463 continue; | 464 continue; |
464 | 465 |
465 CFX_ByteStringC keyNoSlash(key.c_str() + 1, key.GetLength() - 1); | 466 CFX_ByteStringC keyNoSlash(key.c_str() + 1, key.GetLength() - 1); |
466 pDict->SetAt(keyNoSlash, pObj); | 467 pDict->SetAt(keyNoSlash, pObj); |
467 } | 468 } |
468 | 469 |
469 // Only when this is a signature dictionary and has contents, we reset the | 470 // Only when this is a signature dictionary and has contents, we reset the |
470 // contents to the un-decrypted form. | 471 // contents to the un-decrypted form. |
471 if (IsSignatureDict(pDict.get()) && dwSignValuePos) { | 472 if (pDict->IsSignatureDict() && dwSignValuePos) { |
472 CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos); | 473 CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos); |
473 m_Pos = dwSignValuePos; | 474 m_Pos = dwSignValuePos; |
474 pDict->SetAt("Contents", GetObject(pObjList, objnum, gennum, false)); | 475 pDict->SetAt("Contents", GetObject(pObjList, objnum, gennum, false)); |
475 } | 476 } |
476 | 477 |
477 FX_FILESIZE SavedPos = m_Pos; | 478 FX_FILESIZE SavedPos = m_Pos; |
478 CFX_ByteString nextword = GetNextWord(nullptr); | 479 CFX_ByteString nextword = GetNextWord(nullptr); |
479 if (nextword != "stream") { | 480 if (nextword != "stream") { |
480 m_Pos = SavedPos; | 481 m_Pos = SavedPos; |
481 return pDict.release(); | 482 return pDict.release(); |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 if (limit && m_Pos == limit) | 972 if (limit && m_Pos == limit) |
972 return -1; | 973 return -1; |
973 } | 974 } |
974 return -1; | 975 return -1; |
975 } | 976 } |
976 | 977 |
977 void CPDF_SyntaxParser::SetEncrypt( | 978 void CPDF_SyntaxParser::SetEncrypt( |
978 std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler) { | 979 std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler) { |
979 m_pCryptoHandler = std::move(pCryptoHandler); | 980 m_pCryptoHandler = std::move(pCryptoHandler); |
980 } | 981 } |
OLD | NEW |