summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/app.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-29 17:05:08 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-29 17:05:08 -0800
commite5fbd7a170257b455f6ea8c94f71e827e6c3bb8d (patch)
tree1e5410c5f11b2d073cae51868aeb018e2a5c0ef0 /fpdfsdk/src/javascript/app.cpp
parentfe351dbc18e419b0ed9fbe34f2d1fb155b4f7bf1 (diff)
downloadpdfium-e5fbd7a170257b455f6ea8c94f71e827e6c3bb8d.tar.xz
Merge to XFA: Fix botched "CC:" parameter passing in JS_DocmailForm().
Original Review URL: https://codereview.chromium.org/1645413002 . (cherry picked from commit 6902db5cbaf0afb8f2cb4df325e1a4e7d6acd53f) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1648793006 .
Diffstat (limited to 'fpdfsdk/src/javascript/app.cpp')
-rw-r--r--fpdfsdk/src/javascript/app.cpp81
1 files changed, 32 insertions, 49 deletions
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 692873e0f9..057bf7ea58 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -567,67 +567,51 @@ FX_BOOL app::mailMsg(IJS_Context* cc,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- if (params.size() < 1)
- return FALSE;
-
- FX_BOOL bUI = TRUE;
- CFX_WideString cTo = L"";
- CFX_WideString cCc = L"";
- CFX_WideString cBcc = L"";
- CFX_WideString cSubject = L"";
- CFX_WideString cMsg = L"";
-
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- v8::Isolate* isolate = pRuntime->GetIsolate();
-
- if (params[0].GetType() == CJS_Value::VT_object) {
- v8::Local<v8::Object> pObj = params[0].ToV8Object();
-
- v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI");
- bUI = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool();
+ std::vector<CJS_Value> newParams =
+ JS_ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc",
+ L"cBcc", L"cSubject", L"cMsg");
- pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo");
- cTo = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ if (newParams[0].GetType() == CJS_Value::VT_unknown) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+ bool bUI = newParams[0].ToBool();
- pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc");
- cCc = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ CFX_WideString cTo;
+ if (newParams[1].GetType() != CJS_Value::VT_unknown) {
+ cTo = newParams[1].ToCFXWideString();
+ } else {
+ if (!bUI) {
+ // cTo parameter required when UI not invoked.
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ return FALSE;
+ }
+ }
- pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc");
- cBcc =
- CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ CFX_WideString cCc;
+ if (newParams[2].GetType() != CJS_Value::VT_unknown)
+ cCc = newParams[2].ToCFXWideString();
- pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject");
- cSubject =
- CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+ CFX_WideString cBcc;
+ if (newParams[3].GetType() != CJS_Value::VT_unknown)
+ cBcc = newParams[3].ToCFXWideString();
- pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg");
- cMsg =
- CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
- } else {
- if (params.size() < 2)
- return FALSE;
+ CFX_WideString cSubject;
+ if (newParams[4].GetType() != CJS_Value::VT_unknown)
+ cSubject = newParams[4].ToCFXWideString();
- bUI = params[0].ToBool();
- cTo = params[1].ToCFXWideString();
-
- if (params.size() >= 3)
- cCc = params[2].ToCFXWideString();
- if (params.size() >= 4)
- cBcc = params[3].ToCFXWideString();
- if (params.size() >= 5)
- cSubject = params[4].ToCFXWideString();
- if (params.size() >= 6)
- cMsg = params[5].ToCFXWideString();
- }
+ CFX_WideString cMsg;
+ if (newParams[5].GetType() != CJS_Value::VT_unknown)
+ cMsg = newParams[5].ToCFXWideString();
pRuntime->BeginBlock();
- pContext->GetReaderApp()->JS_docmailForm(NULL, 0, bUI, cTo.c_str(),
+ pContext->GetReaderApp()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(),
cSubject.c_str(), cCc.c_str(),
cBcc.c_str(), cMsg.c_str());
pRuntime->EndBlock();
-
- return FALSE;
+ return TRUE;
}
FX_BOOL app::launchURL(IJS_Context* cc,
@@ -646,7 +630,6 @@ FX_BOOL app::runtimeHighlight(IJS_Context* cc,
} else {
vp << m_bRuntimeHighLight;
}
-
return TRUE;
}