summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-10-26 11:00:51 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-26 15:16:56 +0000
commitefc879d226e98ddad36704d78f52037ccf4369dc (patch)
tree50e4510a0ff984d339b08a7a5ea4a26fa90926db /xfa
parent78b334a824c42138f5e98060638b1643b0279602 (diff)
downloadpdfium-efc879d226e98ddad36704d78f52037ccf4369dc.tar.xz
Consistently apply JS size check
This CL makes the use of CXFA_IsTooBig consistent and universal across all of the ToJavascript and related methods. Previously this method was only applied in some calls. It is now being tested as a precondition and postcondition on every call and as a post condition for the entire translation process. There are some size checks within methods that potentially generate large amounts of JS that have been left in. BUG=chromium:752920 Change-Id: I1a8bfe21e0a17c2e47592fc6017060243674f1bc Reviewed-on: https://pdfium-review.googlesource.com/16812 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp3
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.cpp99
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp86
3 files changed, 83 insertions, 105 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index 8c2aeefbbd..2f271d8c60 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -6087,7 +6087,8 @@ bool CXFA_FM2JSContext::Translate(const WideStringView& wsFormcalc,
return false;
wsJavascript->AppendChar(0);
- return true;
+
+ return !CXFA_IsTooBig(*wsJavascript);
}
CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate,
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index 661ce42789..759a875b8d 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -9,6 +9,7 @@
#include <utility>
#include "core/fxcrt/cfx_widetextbuf.h"
+#include "xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h"
#include "xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h"
namespace {
@@ -32,12 +33,12 @@ CXFA_FMExpression::CXFA_FMExpression(uint32_t line, XFA_FM_EXPTYPE type)
bool CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
bool CXFA_FMExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition(
@@ -56,12 +57,12 @@ CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() {}
bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
if (m_isGlobal && m_pExpressions.empty()) {
javascript << L"// comments only";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
if (m_isGlobal) {
javascript << L"(\n";
@@ -98,7 +99,8 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
ret = expr->ToImpliedReturnJS(javascript);
else
ret = expr->ToJavaScript(javascript);
- if (!ret || CXFA_IsTooBig(javascript))
+
+ if (!ret)
return false;
}
javascript << L"return ";
@@ -114,12 +116,12 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
if (m_isGlobal) {
javascript << L").call(this);\n";
}
- return true;
+ return !CXFA_IsTooBig(javascript);
}
-bool CXFA_FMFunctionDefinition::ToImpliedReturnJS(CFX_WideTextBuf&) {
+bool CXFA_FMFunctionDefinition::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
CXFA_FMVarExpression::CXFA_FMVarExpression(
@@ -134,7 +136,7 @@ CXFA_FMVarExpression::~CXFA_FMVarExpression() {}
bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"var ";
@@ -157,12 +159,12 @@ bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
} else {
javascript << L"\"\";\n";
}
- return true;
+ return !CXFA_IsTooBig(javascript);
}
bool CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"var ";
@@ -189,7 +191,7 @@ bool CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << L" = ";
javascript << tempName;
javascript << L";\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMExpExpression::CXFA_FMExpExpression(
@@ -202,7 +204,7 @@ CXFA_FMExpExpression::~CXFA_FMExpExpression() {}
bool CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
bool ret = m_pExpression->ToJavaScript(javascript);
@@ -213,7 +215,7 @@ bool CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
bool CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
if (m_pExpression->GetOperatorToken() == TOKassign)
@@ -231,7 +233,7 @@ bool CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
if (!m_pExpression->ToJavaScript(javascript))
return false;
javascript << L");\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
javascript << RUNTIMEFUNCTIONRETURNVALUE;
@@ -239,7 +241,7 @@ bool CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
if (!m_pExpression->ToJavaScript(javascript))
return false;
javascript << L";\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMBlockExpression::CXFA_FMBlockExpression(
@@ -252,21 +254,21 @@ CXFA_FMBlockExpression::~CXFA_FMBlockExpression() {}
bool CXFA_FMBlockExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"{\n";
for (const auto& expr : m_ExpressionList) {
- if (!expr->ToJavaScript(javascript) || CXFA_IsTooBig(javascript))
+ if (!expr->ToJavaScript(javascript))
return false;
}
javascript << L"}\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
bool CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"{\n";
@@ -276,11 +278,12 @@ bool CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
ret = expr->ToImpliedReturnJS(javascript);
else
ret = expr->ToJavaScript(javascript);
- if (!ret || CXFA_IsTooBig(javascript))
+
+ if (!ret)
return false;
}
javascript << L"}\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMDoExpression::CXFA_FMDoExpression(
@@ -292,7 +295,7 @@ CXFA_FMDoExpression::~CXFA_FMDoExpression() {}
bool CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
return m_pList->ToJavaScript(javascript);
@@ -300,7 +303,7 @@ bool CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
bool CXFA_FMDoExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
return m_pList->ToImpliedReturnJS(javascript);
@@ -320,7 +323,7 @@ CXFA_FMIfExpression::~CXFA_FMIfExpression() {}
bool CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"if (";
@@ -360,7 +363,7 @@ bool CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
bool CXFA_FMIfExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << RUNTIMEFUNCTIONRETURNVALUE;
@@ -403,12 +406,12 @@ CXFA_FMLoopExpression::~CXFA_FMLoopExpression() {}
bool CXFA_FMLoopExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
-bool CXFA_FMLoopExpression::ToImpliedReturnJS(CFX_WideTextBuf&) {
+bool CXFA_FMLoopExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
CXFA_FMWhileExpression::CXFA_FMWhileExpression(
@@ -423,7 +426,7 @@ CXFA_FMWhileExpression::~CXFA_FMWhileExpression() {}
bool CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"while (";
@@ -440,7 +443,7 @@ bool CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
bool CXFA_FMWhileExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << RUNTIMEFUNCTIONRETURNVALUE;
@@ -464,24 +467,24 @@ CXFA_FMBreakExpression::~CXFA_FMBreakExpression() {}
bool CXFA_FMBreakExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << RUNTIMEFUNCTIONRETURNVALUE;
javascript << L" = 0;\n";
javascript << L"break;\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
bool CXFA_FMBreakExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << RUNTIMEFUNCTIONRETURNVALUE;
javascript << L" = 0;\n";
javascript << L"break;\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMContinueExpression::CXFA_FMContinueExpression(uint32_t line)
@@ -491,24 +494,24 @@ CXFA_FMContinueExpression::~CXFA_FMContinueExpression() {}
bool CXFA_FMContinueExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << RUNTIMEFUNCTIONRETURNVALUE;
javascript << L" = 0;\n";
javascript << L"continue;\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
bool CXFA_FMContinueExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << RUNTIMEFUNCTIONRETURNVALUE;
javascript << L" = 0;\n";
javascript << L"continue;\n";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMForExpression::CXFA_FMForExpression(
@@ -531,7 +534,7 @@ CXFA_FMForExpression::~CXFA_FMForExpression() {}
bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"{\nvar ";
@@ -554,8 +557,6 @@ bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
return false;
javascript << L"); ";
javascript << tempVariant;
- if (CXFA_IsTooBig(javascript))
- return false;
javascript << (m_bDirection ? kLessEqual : kGreaterEqual);
javascript << XFA_FM_EXPTypeToString(GETFMVALUE);
@@ -574,8 +575,6 @@ bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (!m_pStep->ToJavaScript(javascript))
return false;
javascript << L")";
- if (CXFA_IsTooBig(javascript))
- return false;
} else {
javascript << L"1";
}
@@ -588,7 +587,7 @@ bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
bool CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << RUNTIMEFUNCTIONRETURNVALUE;
@@ -613,8 +612,6 @@ bool CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
return false;
javascript << L"); ";
javascript << tempVariant;
- if (CXFA_IsTooBig(javascript))
- return false;
javascript << (m_bDirection ? kLessEqual : kGreaterEqual);
javascript << XFA_FM_EXPTypeToString(GETFMVALUE);
@@ -660,7 +657,7 @@ CXFA_FMForeachExpression::~CXFA_FMForeachExpression() {}
bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"{\n";
@@ -685,8 +682,6 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
return false;
if (expr != m_pAccessors.back())
javascript << L", ";
- if (CXFA_IsTooBig(javascript))
- return false;
}
javascript << L");\n";
javascript << L"var ";
@@ -719,7 +714,7 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << RUNTIMEFUNCTIONRETURNVALUE;
@@ -745,8 +740,6 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
return false;
if (expr != m_pAccessors.back())
javascript << L", ";
- if (CXFA_IsTooBig(javascript))
- return false;
}
javascript << L");\n";
javascript << L"var ";
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index 19478405e0..373ba916e9 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -94,12 +94,12 @@ CXFA_FMSimpleExpression::CXFA_FMSimpleExpression(uint32_t line, XFA_FM_TOKEN op)
bool CXFA_FMSimpleExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
bool CXFA_FMSimpleExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
XFA_FM_TOKEN CXFA_FMSimpleExpression::GetOperatorToken() const {
@@ -111,11 +111,11 @@ CXFA_FMNullExpression::CXFA_FMNullExpression(uint32_t line)
bool CXFA_FMNullExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"null";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMNumberExpression::CXFA_FMNumberExpression(uint32_t line,
@@ -126,11 +126,11 @@ CXFA_FMNumberExpression::~CXFA_FMNumberExpression() {}
bool CXFA_FMNumberExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << m_wsNumber;
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMStringExpression::CXFA_FMStringExpression(uint32_t line,
@@ -141,13 +141,13 @@ CXFA_FMStringExpression::~CXFA_FMStringExpression() {}
bool CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
WideString tempStr(m_wsString);
if (tempStr.GetLength() <= 2) {
javascript << tempStr;
- return true;
+ return !CXFA_IsTooBig(javascript);
}
javascript.AppendChar(L'\"');
for (size_t i = 1; i < tempStr.GetLength() - 1; i++) {
@@ -168,7 +168,7 @@ bool CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
}
}
javascript.AppendChar(L'\"');
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMIdentifierExpression::CXFA_FMIdentifierExpression(
@@ -181,7 +181,7 @@ CXFA_FMIdentifierExpression::~CXFA_FMIdentifierExpression() {}
bool CXFA_FMIdentifierExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
WideString tempStr(m_wsIdentifier);
@@ -206,7 +206,7 @@ bool CXFA_FMIdentifierExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
EXCLAMATION_IN_IDENTIFIER + tempStr.Right(tempStr.GetLength() - 1);
}
javascript << tempStr;
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(
@@ -219,7 +219,7 @@ CXFA_FMUnaryExpression::~CXFA_FMUnaryExpression() {}
bool CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
CXFA_FMBinExpression::CXFA_FMBinExpression(
@@ -235,7 +235,7 @@ CXFA_FMBinExpression::~CXFA_FMBinExpression() {}
bool CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- return depthManager.IsWithinMaxDepth();
+ return !CXFA_IsTooBig(javascript) && depthManager.IsWithinMaxDepth();
}
CXFA_FMAssignExpression::CXFA_FMAssignExpression(
@@ -247,7 +247,7 @@ CXFA_FMAssignExpression::CXFA_FMAssignExpression(
bool CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"if (";
@@ -262,8 +262,6 @@ bool CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L"(";
javascript << tempExp1;
javascript << L", ";
- if (CXFA_IsTooBig(javascript))
- return false;
CFX_WideTextBuf tempExp2;
if (!m_pExp2->ToJavaScript(tempExp2))
@@ -287,7 +285,7 @@ bool CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
bool CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"if (";
@@ -304,8 +302,6 @@ bool CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << L"(";
javascript << tempExp1;
javascript << L", ";
- if (CXFA_IsTooBig(javascript))
- return false;
CFX_WideTextBuf tempExp2;
if (!m_pExp2->ToJavaScript(tempExp2))
@@ -338,7 +334,7 @@ CXFA_FMLogicalOrExpression::CXFA_FMLogicalOrExpression(
bool CXFA_FMLogicalOrExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << gs_lpStrExpFuncName[LOGICALOR];
@@ -361,7 +357,7 @@ CXFA_FMLogicalAndExpression::CXFA_FMLogicalAndExpression(
bool CXFA_FMLogicalAndExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << gs_lpStrExpFuncName[LOGICALAND];
@@ -384,7 +380,7 @@ CXFA_FMEqualityExpression::CXFA_FMEqualityExpression(
bool CXFA_FMEqualityExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
switch (m_op) {
@@ -419,7 +415,7 @@ CXFA_FMRelationalExpression::CXFA_FMRelationalExpression(
bool CXFA_FMRelationalExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
switch (m_op) {
@@ -462,7 +458,7 @@ CXFA_FMAdditiveExpression::CXFA_FMAdditiveExpression(
bool CXFA_FMAdditiveExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
switch (m_op) {
@@ -496,7 +492,7 @@ CXFA_FMMultiplicativeExpression::CXFA_FMMultiplicativeExpression(
bool CXFA_FMMultiplicativeExpression::ToJavaScript(
CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
switch (m_op) {
@@ -527,7 +523,7 @@ CXFA_FMPosExpression::CXFA_FMPosExpression(
bool CXFA_FMPosExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << gs_lpStrExpFuncName[POSITIVE];
@@ -535,7 +531,7 @@ bool CXFA_FMPosExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (!m_pExp->ToJavaScript(javascript))
return false;
javascript << L")";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMNegExpression::CXFA_FMNegExpression(
@@ -545,7 +541,7 @@ CXFA_FMNegExpression::CXFA_FMNegExpression(
bool CXFA_FMNegExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << gs_lpStrExpFuncName[NEGATIVE];
@@ -553,7 +549,7 @@ bool CXFA_FMNegExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (!m_pExp->ToJavaScript(javascript))
return false;
javascript << L")";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMNotExpression::CXFA_FMNotExpression(
@@ -563,7 +559,7 @@ CXFA_FMNotExpression::CXFA_FMNotExpression(
bool CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << gs_lpStrExpFuncName[NOT];
@@ -571,7 +567,7 @@ bool CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (!m_pExp->ToJavaScript(javascript))
return false;
javascript << L")";
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMCallExpression::CXFA_FMCallExpression(
@@ -621,7 +617,7 @@ uint32_t CXFA_FMCallExpression::IsMethodWithObjParam(
bool CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
CFX_WideTextBuf funcName;
@@ -649,8 +645,6 @@ bool CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (i + 1 < m_Arguments.size()) {
javascript << L", ";
}
- if (CXFA_IsTooBig(javascript))
- return false;
}
} else {
for (const auto& expr : m_Arguments) {
@@ -661,8 +655,6 @@ bool CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L")";
if (expr != m_Arguments.back())
javascript << L", ";
- if (CXFA_IsTooBig(javascript))
- return false;
}
}
javascript << L")";
@@ -710,8 +702,6 @@ bool CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
return false;
if (expr != m_Arguments.back())
javascript << L", ";
- if (CXFA_IsTooBig(javascript))
- return false;
}
}
javascript << L")";
@@ -719,7 +709,7 @@ bool CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L")";
}
}
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression(
@@ -738,7 +728,7 @@ CXFA_FMDotAccessorExpression::~CXFA_FMDotAccessorExpression() {}
bool CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << gs_lpStrExpFuncName[DOT];
@@ -753,8 +743,6 @@ bool CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
}
javascript << L", ";
javascript << L"\"";
- if (CXFA_IsTooBig(javascript))
- return false;
if (m_pExp1 && m_pExp1->GetOperatorToken() == TOKidentifier)
javascript << tempExp1;
@@ -789,7 +777,7 @@ CXFA_FMIndexExpression::CXFA_FMIndexExpression(
bool CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
switch (m_accessorIndex) {
@@ -817,7 +805,7 @@ bool CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L"0";
}
}
- return true;
+ return !CXFA_IsTooBig(javascript);
}
CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression(
@@ -837,7 +825,7 @@ CXFA_FMDotDotAccessorExpression::~CXFA_FMDotDotAccessorExpression() {}
bool CXFA_FMDotDotAccessorExpression::ToJavaScript(
CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << gs_lpStrExpFuncName[DOTDOT];
@@ -848,8 +836,6 @@ bool CXFA_FMDotDotAccessorExpression::ToJavaScript(
javascript << tempExp1;
javascript << L", ";
javascript << L"\"";
- if (CXFA_IsTooBig(javascript))
- return false;
if (m_pExp1->GetOperatorToken() == TOKidentifier)
javascript << tempExp1;
@@ -874,7 +860,7 @@ CXFA_FMMethodCallExpression::CXFA_FMMethodCallExpression(
bool CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMToJavaScriptDepth depthManager;
- if (!depthManager.IsWithinMaxDepth())
+ if (CXFA_IsTooBig(javascript) || !depthManager.IsWithinMaxDepth())
return false;
javascript << L"(\nfunction ()\n{\n";
@@ -889,8 +875,6 @@ bool CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << L"for(var index = accessor_object.length - 1; index > 1; "
L"index--)\n{\n";
javascript << L"method_return_value = accessor_object[index].";
- if (CXFA_IsTooBig(javascript))
- return false;
CFX_WideTextBuf tempExp2;
if (!m_pExp2->ToJavaScript(tempExp2))
@@ -906,5 +890,5 @@ bool CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
}
bool CXFA_IsTooBig(const CFX_WideTextBuf& javascript) {
- return javascript.GetSize() > 256 * 1024 * 1024;
+ return javascript.GetSize() >= 256 * 1024 * 1024;
}