summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmparser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-20 15:52:31 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-20 15:52:31 +0000
commitdd019e9e8144636c75111565af5b120cf9c0ef9b (patch)
tree6e6153acdf50585cb17b5958b616eef08cdfe209 /xfa/fxfa/fm2js/cxfa_fmparser.cpp
parente53460ff2697299d42518f587c42409b0bd673df (diff)
downloadpdfium-dd019e9e8144636c75111565af5b120cf9c0ef9b.tar.xz
Tighten up assignment instructions in formcalc.
The assignment operator can not be chained. This Cl removes the while loop for assignments and changes it to an if(). We also can not have an assignment inside ()'s so remove that option. Bug: chromium:779349 Change-Id: I6934e18815f843ae8241023df6c03d8bbcd8168d Reviewed-on: https://pdfium-review.googlesource.com/27350 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.cpp36
1 files changed, 8 insertions, 28 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser.cpp b/xfa/fxfa/fm2js/cxfa_fmparser.cpp
index 8baa59fb25..7add9888f8 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparser.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparser.cpp
@@ -15,7 +15,6 @@
namespace {
-constexpr unsigned int kMaxAssignmentChainLength = 12;
constexpr unsigned int kMaxParseDepth = 1250;
constexpr unsigned int kMaxPostExpressions = 16384;
@@ -223,12 +222,12 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParser::ParseDeclarationExpression() {
if (!NextToken())
return nullptr;
- std::unique_ptr<CXFA_FMExpression> expr;
+ std::unique_ptr<CXFA_FMSimpleExpression> expr;
if (m_token.m_type == TOKassign) {
if (!NextToken())
return nullptr;
- expr = ParseExpExpression();
+ expr = ParseSimpleExpression();
if (!expr)
return nullptr;
}
@@ -253,17 +252,15 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParser::ParseExpExpression() {
std::unique_ptr<CXFA_FMSimpleExpression> pExp1 = ParseSimpleExpression();
if (!pExp1)
return nullptr;
- int level = 1;
- while (m_token.m_type == TOKassign) {
+
+ if (m_token.m_type == TOKassign) {
if (!NextToken())
return nullptr;
- std::unique_ptr<CXFA_FMSimpleExpression> pExp2 = ParseLogicalOrExpression();
+
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2 = ParseSimpleExpression();
if (!pExp2)
return nullptr;
- if (level++ == kMaxAssignmentChainLength) {
- m_error = true;
- return nullptr;
- }
+
pExp1 = pdfium::MakeUnique<CXFA_FMAssignExpression>(
line, TOKassign, std::move(pExp1), std::move(pExp2));
}
@@ -913,27 +910,10 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParser::ParseParenExpression() {
return nullptr;
}
- uint32_t line = m_lexer->GetCurrentLine();
- std::unique_ptr<CXFA_FMSimpleExpression> pExp1 = ParseLogicalOrExpression();
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1 = ParseSimpleExpression();
if (!pExp1)
return nullptr;
- int level = 1;
- while (m_token.m_type == TOKassign) {
- if (!NextToken())
- return nullptr;
-
- std::unique_ptr<CXFA_FMSimpleExpression> pExp2 = ParseLogicalOrExpression();
- if (!pExp2)
- return nullptr;
- if (level++ == kMaxAssignmentChainLength) {
- m_error = true;
- return nullptr;
- }
-
- pExp1 = pdfium::MakeUnique<CXFA_FMAssignExpression>(
- line, TOKassign, std::move(pExp1), std::move(pExp2));
- }
if (!CheckThenNext(TOKrparen))
return nullptr;
return pExp1;