Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/include/fsdk_define.h" | 7 #include "fpdfsdk/include/fsdk_define.h" |
| 8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
| 9 #include "fpdfsdk/include/fsdk_mgr.h" | 9 #include "fpdfsdk/include/fsdk_mgr.h" |
| 10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" | 10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1102 srcURL = srcURL.Right(csURL.GetLength() - (pos + 1)); | 1102 srcURL = srcURL.Right(csURL.GetLength() - (pos + 1)); |
| 1103 } | 1103 } |
| 1104 csToAddress.Replace(L",", L";"); | 1104 csToAddress.Replace(L",", L";"); |
| 1105 csCCAddress.Replace(L",", L";"); | 1105 csCCAddress.Replace(L",", L";"); |
| 1106 csBCCAddress.Replace(L",", L";"); | 1106 csBCCAddress.Replace(L",", L";"); |
| 1107 return TRUE; | 1107 return TRUE; |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 FX_BOOL CPDFXFA_Document::_SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit) { | 1110 FX_BOOL CPDFXFA_Document::_SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit) { |
| 1111 #ifdef PDF_ENABLE_XFA | 1111 #ifdef PDF_ENABLE_XFA |
| 1112 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | |
| 1113 if (!pEnv) | |
| 1114 return FALSE; | |
| 1112 CFX_WideStringC csURLC; | 1115 CFX_WideStringC csURLC; |
| 1113 submit.GetSubmitTarget(csURLC); | 1116 submit.GetSubmitTarget(csURLC); |
| 1114 CFX_WideString csURL = csURLC; | 1117 CFX_WideString csURL = csURLC; |
| 1115 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | |
| 1116 if (pEnv == NULL) | |
| 1117 return FALSE; | |
| 1118 if (csURL.IsEmpty()) { | 1118 if (csURL.IsEmpty()) { |
| 1119 CFX_WideString ws; | 1119 CFX_WideString ws; |
| 1120 ws.FromLocal("Submit cancelled."); | 1120 ws.FromLocal("Submit cancelled."); |
| 1121 CFX_ByteString bs = ws.UTF16LE_Encode(); | 1121 CFX_ByteString bs = ws.UTF16LE_Encode(); |
| 1122 int len = bs.GetLength() / sizeof(unsigned short); | 1122 int len = bs.GetLength() / sizeof(unsigned short); |
| 1123 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), | 1123 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), |
| 1124 (FPDF_WIDESTRING)L"", 0, 4); | 1124 (FPDF_WIDESTRING)L"", 0, 4); |
| 1125 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 1125 bs.ReleaseBuffer(len * sizeof(unsigned short)); |
| 1126 return FALSE; | 1126 return FALSE; |
| 1127 } | 1127 } |
| 1128 | |
| 1129 FPDF_BOOL bRet = TRUE; | 1128 FPDF_BOOL bRet = TRUE; |
| 1130 FPDF_FILEHANDLER* pFileHandler = NULL; | 1129 FPDF_FILEHANDLER* pFileHandler = nullptr; |
| 1131 int fileFlag = -1; | 1130 int fileFlag = -1; |
| 1132 | 1131 switch (submit.GetSubmitFormat()) { |
| 1133 if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Xdp) { | 1132 case XFA_ATTRIBUTEENUM_Xdp: { |
| 1134 CFX_WideStringC csContentC; | 1133 CFX_WideStringC csContentC; |
| 1135 submit.GetSubmitXDPContent(csContentC); | 1134 submit.GetSubmitXDPContent(csContentC); |
| 1136 CFX_WideString csContent; | 1135 CFX_WideString csContent; |
| 1137 csContent = csContentC.GetPtr(); | 1136 csContent = csContentC; |
|
jun_fang
2016/02/02 12:06:09
Here is the crashed point.
FXSYS_wcslen was used
| |
| 1138 csContent.TrimLeft(); | 1137 csContent.TrimLeft(); |
| 1139 csContent.TrimRight(); | 1138 csContent.TrimRight(); |
| 1140 CFX_WideString space; | 1139 CFX_WideString space; |
| 1141 space.FromLocal(" "); | 1140 space.FromLocal(" "); |
| 1142 csContent = space + csContent + space; | 1141 csContent = space + csContent + space; |
| 1143 FPDF_DWORD flag = 0; | 1142 FPDF_DWORD flag = 0; |
| 1144 if (submit.IsSubmitEmbedPDF()) | 1143 if (submit.IsSubmitEmbedPDF()) |
| 1145 flag |= FXFA_PDF; | 1144 flag |= FXFA_PDF; |
| 1146 _ToXFAContentFlags(csContent, flag); | 1145 _ToXFAContentFlags(csContent, flag); |
| 1147 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, NULL, "wb"); | 1146 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); |
| 1148 fileFlag = FXFA_SAVEAS_XDP; | 1147 fileFlag = FXFA_SAVEAS_XDP; |
| 1149 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); | 1148 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); |
| 1150 } else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Xml) { | 1149 break; |
| 1151 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, NULL, "wb"); | 1150 } |
| 1152 fileFlag = FXFA_SAVEAS_XML; | 1151 case XFA_ATTRIBUTEENUM_Xml: |
| 1153 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0); | 1152 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
| 1154 } else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Pdf) { | 1153 fileFlag = FXFA_SAVEAS_XML; |
| 1155 // csfilename = csDocName; | 1154 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0); |
| 1156 } else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Formdata) { | 1155 break; |
| 1157 return FALSE; | 1156 case XFA_ATTRIBUTEENUM_Pdf: |
| 1158 } else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Urlencoded) { | 1157 break; |
| 1159 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, NULL, "wb"); | 1158 case XFA_ATTRIBUTEENUM_Urlencoded: |
| 1160 fileFlag = FXFA_SAVEAS_XML; | 1159 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
| 1161 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0); | 1160 fileFlag = FXFA_SAVEAS_XML; |
| 1162 } else if (submit.GetSubmitFormat() == XFA_ATTRIBUTEENUM_Xfd) { | 1161 _ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0); |
| 1163 return FALSE; | 1162 break; |
| 1164 } else { | 1163 default: |
| 1165 return FALSE; | 1164 return false; |
| 1166 } | 1165 } |
| 1167 if (pFileHandler == NULL) | 1166 if (!pFileHandler) |
| 1168 return FALSE; | 1167 return FALSE; |
| 1169 if (0 == csURL.Left(7).CompareNoCase(L"mailto:")) { | 1168 if (0 == csURL.Left(7).CompareNoCase(L"mailto:")) { |
| 1170 CFX_WideString csToAddress; | 1169 CFX_WideString csToAddress; |
| 1171 CFX_WideString csCCAddress; | 1170 CFX_WideString csCCAddress; |
| 1172 CFX_WideString csBCCAddress; | 1171 CFX_WideString csBCCAddress; |
| 1173 CFX_WideString csSubject; | 1172 CFX_WideString csSubject; |
| 1174 CFX_WideString csMsg; | 1173 CFX_WideString csMsg; |
| 1175 | |
| 1176 bRet = _MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, | 1174 bRet = _MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, |
| 1177 csMsg); | 1175 csMsg); |
| 1178 if (FALSE == bRet) | 1176 if (!bRet) |
| 1179 return FALSE; | 1177 return FALSE; |
| 1180 | |
| 1181 CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); | 1178 CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); |
| 1182 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); | 1179 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); |
| 1183 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); | 1180 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); |
| 1184 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); | 1181 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); |
| 1185 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); | 1182 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); |
| 1186 | |
| 1187 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); | 1183 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); |
| 1188 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); | 1184 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); |
| 1189 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); | 1185 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); |
| 1190 FPDF_WIDESTRING pSubject = | 1186 FPDF_WIDESTRING pSubject = |
| 1191 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); | 1187 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); |
| 1192 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); | 1188 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| 1193 | |
| 1194 pEnv->FFI_EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); | 1189 pEnv->FFI_EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); |
| 1195 bsTo.ReleaseBuffer(); | 1190 bsTo.ReleaseBuffer(); |
| 1196 bsCC.ReleaseBuffer(); | 1191 bsCC.ReleaseBuffer(); |
| 1197 bsBcc.ReleaseBuffer(); | 1192 bsBcc.ReleaseBuffer(); |
| 1198 bsSubject.ReleaseBuffer(); | 1193 bsSubject.ReleaseBuffer(); |
| 1199 bsMsg.ReleaseBuffer(); | 1194 bsMsg.ReleaseBuffer(); |
| 1200 } else { | 1195 } else { |
| 1201 // http¡¢ftp | 1196 // http¡¢ftp |
| 1202 CFX_WideString ws; | 1197 CFX_WideString ws; |
| 1203 CFX_ByteString bs = csURL.UTF16LE_Encode(); | 1198 CFX_ByteString bs = csURL.UTF16LE_Encode(); |
| 1204 int len = bs.GetLength() / sizeof(unsigned short); | 1199 int len = bs.GetLength() / sizeof(unsigned short); |
| 1205 pEnv->FFI_UploadTo( | 1200 pEnv->FFI_UploadTo( |
| 1206 pFileHandler, fileFlag, | 1201 pFileHandler, fileFlag, |
| 1207 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short))); | 1202 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short))); |
| 1208 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 1203 bs.ReleaseBuffer(len * sizeof(unsigned short)); |
| 1209 } | 1204 } |
| 1210 | |
| 1211 return bRet; | 1205 return bRet; |
| 1212 #else | 1206 #else |
| 1213 return TRUE; | 1207 return TRUE; |
| 1214 #endif | 1208 #endif |
| 1215 } | 1209 } |
| 1216 | 1210 |
| 1217 FX_BOOL CPDFXFA_Document::SetGlobalProperty(IXFA_Doc* hDoc, | 1211 FX_BOOL CPDFXFA_Document::SetGlobalProperty(IXFA_Doc* hDoc, |
| 1218 const CFX_ByteStringC& szPropName, | 1212 const CFX_ByteStringC& szPropName, |
| 1219 FXJSE_HVALUE hValue) { | 1213 FXJSE_HVALUE hValue) { |
| 1220 if (hDoc != m_pXFADoc) | 1214 if (hDoc != m_pXFADoc) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1256 } | 1250 } |
| 1257 | 1251 |
| 1258 return _GetHValueByName(szPropName, hValue, | 1252 return _GetHValueByName(szPropName, hValue, |
| 1259 m_pSDKDoc->GetEnv()->GetJSRuntime()); | 1253 m_pSDKDoc->GetEnv()->GetJSRuntime()); |
| 1260 } | 1254 } |
| 1261 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, | 1255 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, |
| 1262 FXJSE_HVALUE hValue, | 1256 FXJSE_HVALUE hValue, |
| 1263 IJS_Runtime* runTime) { | 1257 IJS_Runtime* runTime) { |
| 1264 return runTime->GetHValueByName(utf8Name, hValue); | 1258 return runTime->GetHValueByName(utf8Name, hValue); |
| 1265 } | 1259 } |
| OLD | NEW |