diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-04-12 13:13:43 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-12 13:13:43 +0000 |
commit | e1a41afbe146c9a976d96828a3a09a8a384741d9 (patch) | |
tree | 6d6aac6f513d02de07ab6465de5d05aca08a8218 /core/fxcrt/xml/cfx_saxreaderhandler.cpp | |
parent | 87b67f842fe53c3d5db553b6c1965f4588fecbfc (diff) | |
download | pdfium-e1a41afbe146c9a976d96828a3a09a8a384741d9.tar.xz |
[xfa] Remove form checksum abilities
This CL removes the code for verifying and creating checksums associated
with form elements in XFA documents. This was the only code requiring
the SAXReader which has also been removed.
According to the XFA spec and application can decide which parts of the
signatures are supported. This feature is being removed until we
determine if/when it is needed.
Bug: pdfium:1063
Change-Id: Iec2261282340f8fc72a1225d2e0d3e6ddf05edcb
Reviewed-on: https://pdfium-review.googlesource.com/30150
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_saxreaderhandler.cpp')
-rw-r--r-- | core/fxcrt/xml/cfx_saxreaderhandler.cpp | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/core/fxcrt/xml/cfx_saxreaderhandler.cpp b/core/fxcrt/xml/cfx_saxreaderhandler.cpp deleted file mode 100644 index d255ce924d..0000000000 --- a/core/fxcrt/xml/cfx_saxreaderhandler.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "core/fxcrt/xml/cfx_saxreaderhandler.h" - -#include <string> - -#include "core/fxcrt/cfx_checksumcontext.h" - -CFX_SAXReaderHandler::CFX_SAXReaderHandler(CFX_ChecksumContext* pContext) - : m_pContext(pContext) { - ASSERT(m_pContext); -} - -CFX_SAXReaderHandler::~CFX_SAXReaderHandler() {} - -CFX_SAXContext* CFX_SAXReaderHandler::OnTagEnter( - const ByteStringView& bsTagName, - CFX_SAXItem::Type eType, - uint32_t dwStartPos) { - UpdateChecksum(true); - if (eType != CFX_SAXItem::Type::Tag && - eType != CFX_SAXItem::Type::Instruction) { - return nullptr; - } - - m_SAXContext.m_eNode = eType; - m_SAXContext.m_TextBuf << "<"; - if (eType == CFX_SAXItem::Type::Instruction) - m_SAXContext.m_TextBuf << "?"; - - m_SAXContext.m_TextBuf << bsTagName; - m_SAXContext.m_bsTagName = bsTagName; - return &m_SAXContext; -} - -void CFX_SAXReaderHandler::OnTagAttribute(CFX_SAXContext* pTag, - const ByteStringView& bsAttri, - const ByteStringView& bsValue) { - if (!pTag) - return; - pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\""; -} - -void CFX_SAXReaderHandler::OnTagBreak(CFX_SAXContext* pTag) { - if (!pTag) - return; - - pTag->m_TextBuf << ">"; - UpdateChecksum(false); -} - -void CFX_SAXReaderHandler::OnTagData(CFX_SAXContext* pTag, - CFX_SAXItem::Type eType, - const ByteStringView& bsData, - uint32_t dwStartPos) { - if (!pTag) - return; - - if (eType == CFX_SAXItem::Type::CharData) - pTag->m_TextBuf << "<![CDATA["; - - pTag->m_TextBuf << bsData; - if (eType == CFX_SAXItem::Type::CharData) - pTag->m_TextBuf << "]]>"; -} - -void CFX_SAXReaderHandler::OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) { - if (!pTag) - return; - - if (pTag->m_eNode == CFX_SAXItem::Type::Instruction) - pTag->m_TextBuf << "?>"; - else if (pTag->m_eNode == CFX_SAXItem::Type::Tag) - pTag->m_TextBuf << "></" << pTag->m_bsTagName.AsStringView() << ">"; - - UpdateChecksum(false); -} - -void CFX_SAXReaderHandler::OnTagEnd(CFX_SAXContext* pTag, - const ByteStringView& bsTagName, - uint32_t dwEndPos) { - if (!pTag) - return; - - pTag->m_TextBuf << "</" << bsTagName << ">"; - UpdateChecksum(false); -} - -void CFX_SAXReaderHandler::OnTargetData(CFX_SAXContext* pTag, - CFX_SAXItem::Type eType, - const ByteStringView& bsData, - uint32_t dwStartPos) { - if (!pTag && eType != CFX_SAXItem::Type::Comment) - return; - - if (eType == CFX_SAXItem::Type::Comment) { - m_SAXContext.m_TextBuf << "<!--" << bsData << "-->"; - UpdateChecksum(false); - } else { - pTag->m_TextBuf << " " << bsData; - } -} - -void CFX_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) { - int32_t iLength = m_SAXContext.m_TextBuf.tellp(); - if (iLength < 1) - return; - - std::string sBuffer = m_SAXContext.m_TextBuf.str(); - const uint8_t* pBuffer = reinterpret_cast<const uint8_t*>(sBuffer.c_str()); - bool bUpdata = true; - if (bCheckSpace) { - bUpdata = false; - for (int32_t i = 0; i < iLength; i++) { - bUpdata = (pBuffer[i] > 0x20); - if (bUpdata) - break; - } - } - if (bUpdata) - m_pContext->Update(ByteStringView(pBuffer, iLength)); - - m_SAXContext.m_TextBuf.str(""); -} |