| 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/fpdfapi/fpdf_parser/include/cpdf_parser.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 if (m_pSyntax->GetKeyword() != "trailer") | 1472 if (m_pSyntax->GetKeyword() != "trailer") |
| 1473 return nullptr; | 1473 return nullptr; |
| 1474 | 1474 |
| 1475 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( | 1475 std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( |
| 1476 m_pSyntax->GetObject(m_pDocument, 0, 0, true)); | 1476 m_pSyntax->GetObject(m_pDocument, 0, 0, true)); |
| 1477 if (!ToDictionary(pObj.get())) | 1477 if (!ToDictionary(pObj.get())) |
| 1478 return nullptr; | 1478 return nullptr; |
| 1479 return pObj.release()->AsDictionary(); | 1479 return pObj.release()->AsDictionary(); |
| 1480 } | 1480 } |
| 1481 | 1481 |
| 1482 uint32_t CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) { | 1482 uint32_t CPDF_Parser::GetPermissions() const { |
| 1483 if (!m_pSecurityHandler) | 1483 if (!m_pSecurityHandler) |
| 1484 return (uint32_t)-1; | 1484 return 0xFFFFFFFF; |
| 1485 | 1485 |
| 1486 uint32_t dwPermission = m_pSecurityHandler->GetPermissions(); | 1486 uint32_t dwPermission = m_pSecurityHandler->GetPermissions(); |
| 1487 if (m_pEncryptDict && m_pEncryptDict->GetStringBy("Filter") == "Standard") { | 1487 if (m_pEncryptDict && m_pEncryptDict->GetStringBy("Filter") == "Standard") { |
| 1488 // See PDF Reference 1.7, page 123, table 3.20. |
| 1488 dwPermission &= 0xFFFFFFFC; | 1489 dwPermission &= 0xFFFFFFFC; |
| 1489 dwPermission |= 0xFFFFF0C0; | 1490 dwPermission |= 0xFFFFF0C0; |
| 1490 if (bCheckRevision && m_pEncryptDict->GetIntegerBy("R") == 2) | |
| 1491 dwPermission &= 0xFFFFF0FF; | |
| 1492 } | 1491 } |
| 1493 return dwPermission; | 1492 return dwPermission; |
| 1494 } | 1493 } |
| 1495 | 1494 |
| 1496 FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, | 1495 FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, |
| 1497 uint32_t offset) { | 1496 uint32_t offset) { |
| 1498 m_pSyntax->InitParser(pFileAccess, offset); | 1497 m_pSyntax->InitParser(pFileAccess, offset); |
| 1499 m_pSyntax->RestorePos(m_pSyntax->m_HeaderOffset + 9); | 1498 m_pSyntax->RestorePos(m_pSyntax->m_HeaderOffset + 9); |
| 1500 | 1499 |
| 1501 FX_FILESIZE SavedPos = m_pSyntax->SavePos(); | 1500 FX_FILESIZE SavedPos = m_pSyntax->SavePos(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && | 1669 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && |
| 1671 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { | 1670 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { |
| 1672 m_LastXRefOffset = 0; | 1671 m_LastXRefOffset = 0; |
| 1673 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1672 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
| 1674 return FORMAT_ERROR; | 1673 return FORMAT_ERROR; |
| 1675 } | 1674 } |
| 1676 | 1675 |
| 1677 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; | 1676 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; |
| 1678 return SUCCESS; | 1677 return SUCCESS; |
| 1679 } | 1678 } |
| OLD | NEW |