diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-02-20 22:04:09 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-20 22:04:09 +0000 |
commit | ceab166b7dafc2bb514755e4a017bf178d0c8e8b (patch) | |
tree | 48fddd78ff7876fe6013cbb6ed575ac69c043001 /xfa/fxfa/fm2js/cxfa_fmparser.cpp | |
parent | 676658cfccf3f8cf820dfa63a7b6e2f9a76c2e18 (diff) | |
download | pdfium-ceab166b7dafc2bb514755e4a017bf178d0c8e8b.tar.xz |
[formcalc] Do not convert if to an identifier
The if token in formcalc is an internal keyword and can not be used as
an identifier. The current if parsing code will turn if into an
identifier if it fails to find the 'then' statement after the argument
list.
This should be a failed parse instead of coverting if to an identifier
and resetting the lexer.
Change-Id: Ieebf6a1aabc27482fcaeaf7a9bd4be40fc01e9ad
Reviewed-on: https://pdfium-review.googlesource.com/27430
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmparser.cpp')
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmparser.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser.cpp b/xfa/fxfa/fm2js/cxfa_fmparser.cpp index a103183c38..fc8c58511a 100644 --- a/xfa/fxfa/fm2js/cxfa_fmparser.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmparser.cpp @@ -938,8 +938,6 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParser::ParseIfExpression() { AutoRestorer<unsigned long> restorer(&m_parse_depth); if (HasError() || !IncrementParseDepthAndCheck()) return nullptr; - - const wchar_t* pStartPos = m_lexer->GetPos(); if (!NextToken() || !CheckThenNext(TOKlparen)) return nullptr; @@ -955,13 +953,12 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParser::ParseIfExpression() { } if (!CheckThenNext(TOKrparen)) return nullptr; + if (m_token.m_type != TOKthen) { - m_token = CXFA_FMToken(TOKidentifier); - m_token.m_string = L"if"; - m_lexer->SetPos(pStartPos); - return ParseExpExpression(); + m_error = true; + return nullptr; } - if (!CheckThenNext(TOKthen)) + if (!NextToken()) return nullptr; std::unique_ptr<CXFA_FMExpression> pIfExpression = ParseBlockExpression(); |