diff options
author | Lei Zhang <thestig@chromium.org> | 2017-05-10 17:44:53 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-11 01:00:39 +0000 |
commit | 4da1e7623c52572bc8677ac53b908f39543f13b1 (patch) | |
tree | 92f14dd5fb32795c54a326b1b5be3c9146b6cfd6 /xfa/fxfa/fm2js/xfa_expression.cpp | |
parent | bdc4580d450f84f094a93a0227a3f708416bc563 (diff) | |
download | pdfium-4da1e7623c52572bc8677ac53b908f39543f13b1.tar.xz |
Limit XFA FormCalc program translation size.
BUG=chromium:665087,chromium:718492
Change-Id: I09e93b4167ab2c0b3b53641243aa0cbeb5b98c4f
Reviewed-on: https://pdfium-review.googlesource.com/3114
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/xfa_expression.cpp')
-rw-r--r-- | xfa/fxfa/fm2js/xfa_expression.cpp | 323 |
1 files changed, 204 insertions, 119 deletions
diff --git a/xfa/fxfa/fm2js/xfa_expression.cpp b/xfa/fxfa/fm2js/xfa_expression.cpp index c1e451eade..324038f7ed 100644 --- a/xfa/fxfa/fm2js/xfa_expression.cpp +++ b/xfa/fxfa/fm2js/xfa_expression.cpp @@ -18,6 +18,11 @@ const wchar_t RUNTIMEBLOCKTEMPARRAY[] = const wchar_t RUNTIMEBLOCKTEMPARRAYINDEX[] = L"foxit_xfa_formcalc_runtime_block_temp_array_index"; +const wchar_t kLessEqual[] = L" <= "; +const wchar_t kGreaterEqual[] = L" >= "; +const wchar_t kPlusEqual[] = L" += "; +const wchar_t kMinusEqual[] = L" -= "; + } // namespace CXFA_FMExpression::CXFA_FMExpression(uint32_t line) @@ -26,9 +31,13 @@ CXFA_FMExpression::CXFA_FMExpression(uint32_t line) CXFA_FMExpression::CXFA_FMExpression(uint32_t line, XFA_FM_EXPTYPE type) : m_type(type), m_line(line) {} -void CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} +bool CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + return true; +} -void CXFA_FMExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {} +bool CXFA_FMExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + return true; +} CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( uint32_t line, @@ -44,10 +53,10 @@ CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() {} -void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { if (m_isGlobal && m_pExpressions.empty()) { javascript << L"// comments only"; - return; + return true; } if (m_isGlobal) { javascript << L"(\n"; @@ -78,10 +87,13 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = null;\n"; for (const auto& expr : m_pExpressions) { + bool ret; if (expr == m_pExpressions.back()) - expr->ToImpliedReturnJS(javascript); + ret = expr->ToImpliedReturnJS(javascript); else - expr->ToJavaScript(javascript); + ret = expr->ToJavaScript(javascript); + if (!ret || CFXA_IsTooBig(javascript)) + return false; } javascript << L"return "; if (m_isGlobal) { @@ -96,9 +108,12 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { if (m_isGlobal) { javascript << L").call(this);\n"; } + return true; } -void CXFA_FMFunctionDefinition::ToImpliedReturnJS(CFX_WideTextBuf&) {} +bool CXFA_FMFunctionDefinition::ToImpliedReturnJS(CFX_WideTextBuf&) { + return true; +} CXFA_FMVarExpression::CXFA_FMVarExpression( uint32_t line, @@ -110,7 +125,7 @@ CXFA_FMVarExpression::CXFA_FMVarExpression( CXFA_FMVarExpression::~CXFA_FMVarExpression() {} -void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"var "; CFX_WideString tempName(m_wsName); if (m_wsName.GetAt(0) == L'!') { @@ -119,7 +134,8 @@ void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << tempName; javascript << L" = "; if (m_pInit) { - m_pInit->ToJavaScript(javascript); + if (!m_pInit->ToJavaScript(javascript)) + return false; javascript << tempName; javascript << L" = "; javascript << XFA_FM_EXPTypeToString(VARFILTER); @@ -129,9 +145,10 @@ void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { } else { javascript << L"\"\";\n"; } + return true; } -void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { +bool CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L"var "; CFX_WideString tempName(m_wsName); if (m_wsName.GetAt(0) == L'!') { @@ -140,7 +157,8 @@ void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << tempName; javascript << L" = "; if (m_pInit) { - m_pInit->ToJavaScript(javascript); + if (!m_pInit->ToJavaScript(javascript)) + return false; javascript << tempName; javascript << L" = "; javascript << XFA_FM_EXPTypeToString(VARFILTER); @@ -154,6 +172,7 @@ void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L" = "; javascript << tempName; javascript << L";\n"; + return true; } CXFA_FMExpExpression::CXFA_FMExpExpression( @@ -164,37 +183,38 @@ CXFA_FMExpExpression::CXFA_FMExpExpression( CXFA_FMExpExpression::~CXFA_FMExpExpression() {} -void CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - if (m_pExpression->GetOperatorToken() == TOKassign) { - m_pExpression->ToJavaScript(javascript); - } else { - m_pExpression->ToJavaScript(javascript); +bool CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + bool ret = m_pExpression->ToJavaScript(javascript); + if (m_pExpression->GetOperatorToken() != TOKassign) javascript << L";\n"; - } + return ret; } -void CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - if (m_pExpression->GetOperatorToken() == TOKassign) { - m_pExpression->ToImpliedReturnJS(javascript); - } else { - if (m_pExpression->GetOperatorToken() == TOKstar || - m_pExpression->GetOperatorToken() == TOKdotstar || - m_pExpression->GetOperatorToken() == TOKdotscream || - m_pExpression->GetOperatorToken() == TOKdotdot || - m_pExpression->GetOperatorToken() == TOKdot) { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << L" = "; - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << L"("; - m_pExpression->ToJavaScript(javascript); - javascript << L");\n"; - } else { - javascript << RUNTIMEFUNCTIONRETURNVALUE; - javascript << L" = "; - m_pExpression->ToJavaScript(javascript); - javascript << L";\n"; - } +bool CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + if (m_pExpression->GetOperatorToken() == TOKassign) + return m_pExpression->ToImpliedReturnJS(javascript); + + if (m_pExpression->GetOperatorToken() == TOKstar || + m_pExpression->GetOperatorToken() == TOKdotstar || + m_pExpression->GetOperatorToken() == TOKdotscream || + m_pExpression->GetOperatorToken() == TOKdotdot || + m_pExpression->GetOperatorToken() == TOKdot) { + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << L" = "; + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << L"("; + if (!m_pExpression->ToJavaScript(javascript)) + return false; + javascript << L");\n"; + return true; } + + javascript << RUNTIMEFUNCTIONRETURNVALUE; + javascript << L" = "; + if (!m_pExpression->ToJavaScript(javascript)) + return false; + javascript << L";\n"; + return true; } CXFA_FMBlockExpression::CXFA_FMBlockExpression( @@ -205,22 +225,29 @@ CXFA_FMBlockExpression::CXFA_FMBlockExpression( CXFA_FMBlockExpression::~CXFA_FMBlockExpression() {} -void CXFA_FMBlockExpression::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMBlockExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"{\n"; - for (const auto& expr : m_ExpressionList) - expr->ToJavaScript(javascript); + for (const auto& expr : m_ExpressionList) { + if (!expr->ToJavaScript(javascript) || CFXA_IsTooBig(javascript)) + return false; + } javascript << L"}\n"; + return true; } -void CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { +bool CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L"{\n"; for (const auto& expr : m_ExpressionList) { + bool ret; if (expr == m_ExpressionList.back()) - expr->ToImpliedReturnJS(javascript); + ret = expr->ToImpliedReturnJS(javascript); else - expr->ToJavaScript(javascript); + ret = expr->ToJavaScript(javascript); + if (!ret || CFXA_IsTooBig(javascript)) + return false; } javascript << L"}\n"; + return true; } CXFA_FMDoExpression::CXFA_FMDoExpression( @@ -230,12 +257,12 @@ CXFA_FMDoExpression::CXFA_FMDoExpression( CXFA_FMDoExpression::~CXFA_FMDoExpression() {} -void CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf& javascript) { - m_pList->ToJavaScript(javascript); +bool CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + return m_pList->ToJavaScript(javascript); } -void CXFA_FMDoExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { - m_pList->ToImpliedReturnJS(javascript); +bool CXFA_FMDoExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { + return m_pList->ToImpliedReturnJS(javascript); } CXFA_FMIfExpression::CXFA_FMIfExpression( @@ -250,63 +277,88 @@ CXFA_FMIfExpression::CXFA_FMIfExpression( CXFA_FMIfExpression::~CXFA_FMIfExpression() {} -void CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"if ("; if (m_pExpression) { javascript << XFA_FM_EXPTypeToString(GETFMVALUE); javascript << L"("; - m_pExpression->ToJavaScript(javascript); + if (!m_pExpression->ToJavaScript(javascript)) + return false; javascript << L")"; } javascript << L")\n"; + if (CFXA_IsTooBig(javascript)) + return false; + if (m_pIfExpression) { - m_pIfExpression->ToJavaScript(javascript); + if (!m_pIfExpression->ToJavaScript(javascript)) + return false; + if (CFXA_IsTooBig(javascript)) + return false; } + if (m_pElseExpression) { if (m_pElseExpression->GetExpType() == XFA_FM_EXPTYPE_IF) { javascript << L"else\n"; javascript << L"{\n"; - m_pElseExpression->ToJavaScript(javascript); + if (!m_pElseExpression->ToJavaScript(javascript)) + return false; javascript << L"}\n"; } else { javascript << L"else\n"; - m_pElseExpression->ToJavaScript(javascript); + if (!m_pElseExpression->ToJavaScript(javascript)) + return false; } } + return !CFXA_IsTooBig(javascript); } -void CXFA_FMIfExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { +bool CXFA_FMIfExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = 0;\n"; javascript << L"if ("; if (m_pExpression) { javascript << XFA_FM_EXPTypeToString(GETFMVALUE); javascript << L"("; - m_pExpression->ToJavaScript(javascript); + if (!m_pExpression->ToJavaScript(javascript)) + return false; javascript << L")"; } javascript << L")\n"; + if (CFXA_IsTooBig(javascript)) + return false; + if (m_pIfExpression) { - m_pIfExpression->ToImpliedReturnJS(javascript); + if (!m_pIfExpression->ToImpliedReturnJS(javascript)) + return false; + if (CFXA_IsTooBig(javascript)) + return false; } if (m_pElseExpression) { if (m_pElseExpression->GetExpType() == XFA_FM_EXPTYPE_IF) { javascript << L"else\n"; javascript << L"{\n"; - m_pElseExpression->ToImpliedReturnJS(javascript); + if (!m_pElseExpression->ToImpliedReturnJS(javascript)) + return false; javascript << L"}\n"; } else { javascript << L"else\n"; - m_pElseExpression->ToImpliedReturnJS(javascript); + if (!m_pElseExpression->ToImpliedReturnJS(javascript)) + return false; } } + return !CFXA_IsTooBig(javascript); } CXFA_FMLoopExpression::~CXFA_FMLoopExpression() {} -void CXFA_FMLoopExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} +bool CXFA_FMLoopExpression::ToJavaScript(CFX_WideTextBuf& javascript) { + return true; +} -void CXFA_FMLoopExpression::ToImpliedReturnJS(CFX_WideTextBuf&) {} +bool CXFA_FMLoopExpression::ToImpliedReturnJS(CFX_WideTextBuf&) { + return true; +} CXFA_FMWhileExpression::CXFA_FMWhileExpression( uint32_t line, @@ -318,20 +370,32 @@ CXFA_FMWhileExpression::CXFA_FMWhileExpression( CXFA_FMWhileExpression::~CXFA_FMWhileExpression() {} -void CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"while ("; - m_pCondition->ToJavaScript(javascript); + if (!m_pCondition->ToJavaScript(javascript)) + return false; javascript << L")\n"; - m_pExpression->ToJavaScript(javascript); + if (CFXA_IsTooBig(javascript)) + return false; + + if (!m_pExpression->ToJavaScript(javascript)) + return false; + return !CFXA_IsTooBig(javascript); } -void CXFA_FMWhileExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { +bool CXFA_FMWhileExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = 0;\n"; javascript << L"while ("; - m_pCondition->ToJavaScript(javascript); + if (!m_pCondition->ToJavaScript(javascript)) + return false; javascript << L")\n"; - m_pExpression->ToImpliedReturnJS(javascript); + if (CFXA_IsTooBig(javascript)) + return false; + + if (!m_pExpression->ToImpliedReturnJS(javascript)) + return false; + return !CFXA_IsTooBig(javascript); } CXFA_FMBreakExpression::CXFA_FMBreakExpression(uint32_t line) @@ -339,16 +403,18 @@ CXFA_FMBreakExpression::CXFA_FMBreakExpression(uint32_t line) CXFA_FMBreakExpression::~CXFA_FMBreakExpression() {} -void CXFA_FMBreakExpression::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMBreakExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = 0;\n"; javascript << L"break;\n"; + return true; } -void CXFA_FMBreakExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { +bool CXFA_FMBreakExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = 0;\n"; javascript << L"break;\n"; + return true; } CXFA_FMContinueExpression::CXFA_FMContinueExpression(uint32_t line) @@ -356,16 +422,18 @@ CXFA_FMContinueExpression::CXFA_FMContinueExpression(uint32_t line) CXFA_FMContinueExpression::~CXFA_FMContinueExpression() {} -void CXFA_FMContinueExpression::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMContinueExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = 0;\n"; javascript << L"continue;\n"; + return true; } -void CXFA_FMContinueExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { +bool CXFA_FMContinueExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = 0;\n"; javascript << L"continue;\n"; + return true; } CXFA_FMForExpression::CXFA_FMForExpression( @@ -380,13 +448,13 @@ CXFA_FMForExpression::CXFA_FMForExpression( m_wsVariant(wsVariant), m_pAssignment(std::move(pAssignment)), m_pAccessor(std::move(pAccessor)), - m_iDirection(iDirection), + m_bDirection(iDirection == 1), m_pStep(std::move(pStep)), m_pList(std::move(pList)) {} CXFA_FMForExpression::~CXFA_FMForExpression() {} -void CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"{\nvar "; CFX_WideString tempVariant; if (m_wsVariant.GetAt(0) == L'!') { @@ -402,40 +470,43 @@ void CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L" = "; javascript << XFA_FM_EXPTypeToString(GETFMVALUE); javascript << L"("; - m_pAssignment->ToJavaScript(javascript); + if (!m_pAssignment->ToJavaScript(javascript)) + return false; javascript << L"); "; javascript << tempVariant; - if (m_iDirection == 1) { - javascript << L" <= "; - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << L"("; - m_pAccessor->ToJavaScript(javascript); - javascript << L"); "; - javascript << tempVariant; - javascript << L" += "; - } else { - javascript << L" >= "; - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << L"("; - m_pAccessor->ToJavaScript(javascript); - javascript << L"); "; - javascript << tempVariant; - javascript << L" -= "; - } + if (CFXA_IsTooBig(javascript)) + return false; + + javascript << (m_bDirection ? kLessEqual : kGreaterEqual); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << L"("; + if (!m_pAccessor->ToJavaScript(javascript)) + return false; + javascript << L"); "; + javascript << tempVariant; + javascript << (m_bDirection ? kPlusEqual : kMinusEqual); + if (CFXA_IsTooBig(javascript)) + return false; + if (m_pStep) { javascript << XFA_FM_EXPTypeToString(GETFMVALUE); javascript << L"("; - m_pStep->ToJavaScript(javascript); + if (!m_pStep->ToJavaScript(javascript)) + return false; javascript << L")"; + if (CFXA_IsTooBig(javascript)) + return false; } else { javascript << L"1"; } javascript << L")\n"; - m_pList->ToJavaScript(javascript); + if (!m_pList->ToJavaScript(javascript)) + return false; javascript << L"}\n"; + return !CFXA_IsTooBig(javascript); } -void CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { +bool CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = 0;\n"; javascript << L"{\nvar "; @@ -453,37 +524,41 @@ void CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L" = "; javascript << XFA_FM_EXPTypeToString(GETFMVALUE); javascript << L"("; - m_pAssignment->ToJavaScript(javascript); + if (!m_pAssignment->ToJavaScript(javascript)) + return false; javascript << L"); "; javascript << tempVariant; - if (m_iDirection == 1) { - javascript << L" <= "; - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << L"("; - m_pAccessor->ToJavaScript(javascript); - javascript << L"); "; - javascript << tempVariant; - javascript << L" += "; - } else { - javascript << L" >= "; - javascript << XFA_FM_EXPTypeToString(GETFMVALUE); - javascript << L"("; - m_pAccessor->ToJavaScript(javascript); - javascript << L"); "; - javascript << tempVariant; - javascript << L" -= "; - } + if (CFXA_IsTooBig(javascript)) + return false; + + javascript << (m_bDirection ? kLessEqual : kGreaterEqual); + javascript << XFA_FM_EXPTypeToString(GETFMVALUE); + javascript << L"("; + if (!m_pAccessor->ToJavaScript(javascript)) + return false; + javascript << L"); "; + javascript << tempVariant; + javascript << L" += "; + javascript << (m_bDirection ? kPlusEqual : kMinusEqual); + if (CFXA_IsTooBig(javascript)) + return false; + if (m_pStep) { javascript << XFA_FM_EXPTypeToString(GETFMVALUE); javascript << L"("; - m_pStep->ToJavaScript(javascript); + if (!m_pStep->ToJavaScript(javascript)) + return false; javascript << L")"; + if (CFXA_IsTooBig(javascript)) + return false; } else { javascript << L"1"; } javascript << L")\n"; - m_pList->ToImpliedReturnJS(javascript); + if (!m_pList->ToImpliedReturnJS(javascript)) + return false; javascript << L"}\n"; + return !CFXA_IsTooBig(javascript); } CXFA_FMForeachExpression::CXFA_FMForeachExpression( @@ -498,7 +573,7 @@ CXFA_FMForeachExpression::CXFA_FMForeachExpression( CXFA_FMForeachExpression::~CXFA_FMForeachExpression() {} -void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { +bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"{\n"; javascript << L"var "; if (m_wsIdentifier.GetAt(0) == L'!') { @@ -516,9 +591,12 @@ void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"("; for (const auto& expr : m_pAccessors) { - expr->ToJavaScript(javascript); + if (!expr->ToJavaScript(javascript)) + return false; if (expr != m_pAccessors.back()) javascript << L", "; + if (CFXA_IsTooBig(javascript)) + return false; } javascript << L");\n"; javascript << L"var "; @@ -541,12 +619,14 @@ void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"["; javascript << RUNTIMEBLOCKTEMPARRAYINDEX; javascript << L"++];\n"; - m_pList->ToJavaScript(javascript); + if (!m_pList->ToJavaScript(javascript)) + return false; javascript << L"}\n"; javascript << L"}\n"; + return !CFXA_IsTooBig(javascript); } -void CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { +bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << L" = 0;\n"; javascript << L"{\n"; @@ -565,9 +645,12 @@ void CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << XFA_FM_EXPTypeToString(CONCATFMOBJECT); javascript << L"("; for (const auto& expr : m_pAccessors) { - expr->ToJavaScript(javascript); + if (!expr->ToJavaScript(javascript)) + return false; if (expr != m_pAccessors.back()) javascript << L", "; + if (CFXA_IsTooBig(javascript)) + return false; } javascript << L");\n"; javascript << L"var "; @@ -590,7 +673,9 @@ void CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L"["; javascript << RUNTIMEBLOCKTEMPARRAYINDEX; javascript << L"++];\n"; - m_pList->ToImpliedReturnJS(javascript); + if (!m_pList->ToImpliedReturnJS(javascript)) + return false; javascript << L"}\n"; javascript << L"}\n"; + return !CFXA_IsTooBig(javascript); } |