summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-23 18:02:57 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-23 18:02:57 +0000
commit0784c7317e3aaa2c65d098cf2593b6b49986307d (patch)
treea264d06dcd9fd0d914324d5bd0a96430cc543b87 /fpdfsdk/fpdfxfa
parent9f71afb882a9d1294f8a4392b8553e2c285f51c7 (diff)
downloadpdfium-0784c7317e3aaa2c65d098cf2593b6b49986307d.tar.xz
Disable JavaScript entirely if no JSPlatform passed by embedder.
Allows run-time selection of whether to permit JS inside PDF. Previously, this was a link-time decision only. This requires a little more caution before we decide that we have the CJS_Runtime, and not the CJS_RuntimeStub in a few casts. Adds a kDisableJavaScript option to the form fill embeddertests. Adds a --disable-javascript flag to the pdfium_test executable. Also adds a --disable-xfa flag while we're at it. Change-Id: I8d8ac95f6474459cadba9a60572fbb342e984646 Reviewed-on: https://pdfium-review.googlesource.com/31090 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index c85c1bd27e..7d1b28be70 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -81,11 +81,11 @@ void CPDFXFA_Context::SetFormFillEnv(
bool CPDFXFA_Context::LoadXFADoc() {
m_nLoadStatus = FXFA_LOADSTATUS_LOADING;
+ m_XFAPageList.clear();
+
if (!m_pPDFDoc)
return false;
- m_XFAPageList.clear();
-
CXFA_FFApp* pApp = GetXFAApp();
if (!pApp)
return false;
@@ -96,8 +96,13 @@ bool CPDFXFA_Context::LoadXFADoc() {
return false;
}
- m_pXFADoc->GetXFADoc()->InitScriptContext(GetCJSRuntime());
+ CJS_Runtime* actual_runtime = GetCJSRuntime(); // Null if a stub.
+ if (!actual_runtime) {
+ SetLastError(FPDF_ERR_XFALOAD);
+ return false;
+ }
+ m_pXFADoc->GetXFADoc()->InitScriptContext(actual_runtime);
if (m_pXFADoc->GetFormType() == FormType::kXFAFull)
m_FormType = FormType::kXFAFull;
else
@@ -113,7 +118,6 @@ bool CPDFXFA_Context::LoadXFADoc() {
m_pXFADocView->DoLayout();
m_pXFADocView->StopLayout();
m_nLoadStatus = FXFA_LOADSTATUS_LOADED;
-
return true;
}
@@ -196,8 +200,7 @@ CJS_Runtime* CPDFXFA_Context::GetCJSRuntime() const {
if (!m_pFormFillEnv)
return nullptr;
- // XFA requires V8, if we have V8 then we have a CJS_Runtime and not the stub.
- return static_cast<CJS_Runtime*>(m_pFormFillEnv->GetIJSRuntime());
+ return m_pFormFillEnv->GetIJSRuntime()->AsCJSRuntime();
}
WideString CPDFXFA_Context::GetAppTitle() const {