From 1b54bc1474af7923f6b82496924978cb87844ff0 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 25 Jul 2018 17:26:28 +0000 Subject: Disable submit in XFA forms. Bug: chromium:842503 Change-Id: If411815d8324929f482e3cad0fda54f24d370c2a Reviewed-on: https://pdfium-review.googlesource.com/37830 Reviewed-by: Tom Sepez Commit-Queue: Henrique Nakashima --- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 4 ++++ fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h | 5 +++++ xfa/fxfa/fxfa.h | 3 +++ xfa/fxfa/parser/cxfa_event.cpp | 2 ++ xfa/fxfa/parser/cxfa_event.h | 4 ++++ xfa/fxfa/parser/cxfa_node.cpp | 6 ++++++ 6 files changed, 24 insertions(+) diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 9d1ceacf02..269b6d4b2f 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -613,6 +613,7 @@ FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { pInterForm->GetHighlightColor(FormFieldType::kXFA)); } +#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED bool CPDFXFA_DocEnvironment::NotifySubmit(bool bPrevOrPost) { if (bPrevOrPost) return OnBeforeNotifySubmit(); @@ -702,6 +703,7 @@ bool CPDFXFA_DocEnvironment::Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) { NotifySubmit(false); return ret; } +#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED RetainPtr CPDFXFA_DocEnvironment::OpenLinkedFile( CXFA_FFDoc* hDoc, @@ -901,6 +903,7 @@ bool CPDFXFA_DocEnvironment::MailToInfo(WideString& csURL, return true; } +#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc, CXFA_Submit* submit) { CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); @@ -978,6 +981,7 @@ bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc, pFormFillEnv->UploadTo(pFileHandler, fileFlag, AsFPDFWideString(&bs)); return true; } +#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED bool CPDFXFA_DocEnvironment::SetPropertyInNonXFAGlobalObject( CXFA_FFDoc* hDoc, diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h index 1c46a37fe8..33e04ed376 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h @@ -62,7 +62,9 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { uint32_t dwOptions) override; FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override; +#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) override; +#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED bool GetPropertyFromNonXFAGlobalObject(CXFA_FFDoc* hDoc, const ByteStringView& szPropName, @@ -76,10 +78,13 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { const WideString& wsLink) override; private: +#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED bool OnBeforeNotifySubmit(); void OnAfterNotifySubmit(); bool NotifySubmit(bool bPrevOrPost); bool SubmitInternal(CXFA_FFDoc* hDoc, CXFA_Submit* submit); +#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED + bool MailToInfo(WideString& csURL, WideString& csToAddress, WideString& csCCAddress, diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index c1fdd2bcb7..6de20f0fbc 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -260,7 +260,10 @@ class IXFA_DocEnvironment { uint32_t dwOptions) = 0; virtual FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) = 0; +#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED virtual bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) = 0; +#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED + virtual bool GetPropertyFromNonXFAGlobalObject( CXFA_FFDoc* hDoc, const ByteStringView& szPropName, diff --git a/xfa/fxfa/parser/cxfa_event.cpp b/xfa/fxfa/parser/cxfa_event.cpp index 3dfa8b870e..8b4a0b56a2 100644 --- a/xfa/fxfa/parser/cxfa_event.cpp +++ b/xfa/fxfa/parser/cxfa_event.cpp @@ -73,6 +73,8 @@ CXFA_Script* CXFA_Event::GetScriptIfExists() { return GetChild(0, XFA_Element::Script, false); } +#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED CXFA_Submit* CXFA_Event::GetSubmitIfExists() { return GetChild(0, XFA_Element::Submit, false); } +#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED diff --git a/xfa/fxfa/parser/cxfa_event.h b/xfa/fxfa/parser/cxfa_event.h index a410805675..6902b52eef 100644 --- a/xfa/fxfa/parser/cxfa_event.h +++ b/xfa/fxfa/parser/cxfa_event.h @@ -20,7 +20,11 @@ class CXFA_Event : public CXFA_Node { XFA_AttributeEnum GetActivity(); XFA_Element GetEventType() const; CXFA_Script* GetScriptIfExists(); + +#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED CXFA_Submit* GetSubmitIfExists(); +#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED + WideString GetRef(); }; diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 5f919b7b14..363af54028 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -2008,11 +2008,17 @@ int32_t CXFA_Node::ProcessEvent(CXFA_FFDocView* docView, case XFA_Element::SignData: break; case XFA_Element::Submit: { +// TODO(crbug.com/867485): Submit is disabled for now. Fix it and reenable this +// code. +#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED CXFA_Submit* submit = event->GetSubmitIfExists(); if (!submit) return XFA_EVENTERROR_NotExist; return docView->GetDoc()->GetDocEnvironment()->Submit(docView->GetDoc(), submit); +#else + return XFA_EVENTERROR_Disabled; +#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED } default: break; -- cgit v1.2.3