|
273 | 273 | }
|
274 | 274 |
|
275 | 275 | if ($_FILES['userfile']['error'][$currentAttachmentNo] === UPLOAD_ERR_OK) {
|
276 |
| - // check the size of the attachment |
277 |
| - $attachmentSize += $_FILES['userfile']['size'][$currentAttachmentNo]; |
278 |
| - if ($attachmentSize > Email::getMaxAttachmentSize()) { |
279 |
| - $gMessage->show($gL10n->get('SYS_ATTACHMENT_TO_LARGE')); |
280 |
| - // => EXIT |
281 |
| - } |
282 |
| - |
283 |
| - // set file type to standard if not given |
284 |
| - if (strlen($_FILES['userfile']['type'][$currentAttachmentNo]) <= 0) { |
285 |
| - $_FILES['userfile']['type'][$currentAttachmentNo] = 'application/octet-stream'; |
286 |
| - } |
287 |
| - |
288 |
| - // add the attachment to the email and message object |
289 | 276 | try {
|
| 277 | + // check filename and throw exception if something is wrong |
| 278 | + StringUtils::strIsValidFileName($_FILES['userfile']['name'][$currentAttachmentNo], false); |
| 279 | + |
| 280 | + // check for valid file extension of attachment |
| 281 | + if(!FileSystemUtils::allowedFileExtension($_FILES['userfile']['name'][$currentAttachmentNo])) { |
| 282 | + $gMessage->show($gL10n->get('SYS_FILE_EXTENSION_INVALID')); |
| 283 | + // => EXIT |
| 284 | + } |
| 285 | + |
| 286 | + // check the size of the attachment |
| 287 | + $attachmentSize += $_FILES['userfile']['size'][$currentAttachmentNo]; |
| 288 | + if ($attachmentSize > Email::getMaxAttachmentSize()) { |
| 289 | + $gMessage->show($gL10n->get('SYS_ATTACHMENT_TO_LARGE')); |
| 290 | + // => EXIT |
| 291 | + } |
| 292 | + |
| 293 | + // set file type to standard if not given |
| 294 | + if (strlen($_FILES['userfile']['type'][$currentAttachmentNo]) <= 0) { |
| 295 | + $_FILES['userfile']['type'][$currentAttachmentNo] = 'application/octet-stream'; |
| 296 | + } |
| 297 | + |
| 298 | + // add the attachment to the email and message object |
290 | 299 | $email->addAttachment($_FILES['userfile']['tmp_name'][$currentAttachmentNo], $_FILES['userfile']['name'][$currentAttachmentNo], $encoding = 'base64', $_FILES['userfile']['type'][$currentAttachmentNo]);
|
291 | 300 | $message->addAttachment($_FILES['userfile']['tmp_name'][$currentAttachmentNo], $_FILES['userfile']['name'][$currentAttachmentNo]);
|
292 | 301 | } catch (Exception $e) {
|
|
0 commit comments