summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_document.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-01 17:02:54 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-01 17:02:54 +0000
commitba367068887aca9f700289aa1b8c198920ca39a2 (patch)
treeee04f81558512f9836e5bdb7a06198dd41d15894 /xfa/fxfa/parser/cxfa_document.cpp
parent048afc6aba4848d5296affb4335500f960262580 (diff)
downloadpdfium-ba367068887aca9f700289aa1b8c198920ca39a2.tar.xz
Fixes XML Instruction handling in CXFA_DocumentParser.
This CL fixes issues with handling XML instructions in CXFA_DocumentParser. Unittests were added to verify the behaviour. Change-Id: Iff8d51d0e6d411419473c9b2c32c700d4bbf86f5 Reviewed-on: https://pdfium-review.googlesource.com/31810 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_document.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 6860c83376..9e5143c5a4 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -1447,17 +1447,19 @@ CFXJSE_Engine* CXFA_Document::GetScriptContext() const {
XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber(
const WideString& wsTemplateNS) {
WideStringView wsTemplateURIPrefix(kTemplateNS);
- size_t nPrefixLength = wsTemplateURIPrefix.GetLength();
- if (WideStringView(wsTemplateNS.c_str(), wsTemplateNS.GetLength()) !=
- wsTemplateURIPrefix) {
+ if (wsTemplateNS.GetLength() <= wsTemplateURIPrefix.GetLength())
return XFA_VERSION_UNKNOWN;
- }
- auto nDotPos = wsTemplateNS.Find('.', nPrefixLength);
+
+ size_t prefixLength = wsTemplateURIPrefix.GetLength();
+ if (WideStringView(wsTemplateNS.c_str(), prefixLength) != wsTemplateURIPrefix)
+ return XFA_VERSION_UNKNOWN;
+
+ auto nDotPos = wsTemplateNS.Find('.', prefixLength);
if (!nDotPos.has_value())
return XFA_VERSION_UNKNOWN;
int8_t iMajor = FXSYS_wtoi(
- wsTemplateNS.Mid(nPrefixLength, nDotPos.value() - nPrefixLength).c_str());
+ wsTemplateNS.Mid(prefixLength, nDotPos.value() - prefixLength).c_str());
int8_t iMinor =
FXSYS_wtoi(wsTemplateNS
.Mid(nDotPos.value() + 1,