| @@ -406,9 +406,9 @@ | ||
| 406 | 406 | } |
| 407 | 407 | } else { |
| 408 | 408 | $this->_message->html .= ' '.trim(preg_replace('#(charset=".*?\r\n)|Content-(Type|ID|Disposition|Transfer-Encoding):.*?\r\n#is', "", $segment)); |
| 409 | 409 | } |
| 410 | - } elseif (preg_match("#Content-Type: .*?/(png|jpg|jpeg|gif)#i", $segment) !== false) { | |
| 410 | + } elseif (preg_match("#Content-Type: .*?/(png|jpg|jpeg|gif)#i", $segment) === 1) { | |
| 411 | 411 | preg_match('#name="([^"]+)"#i', $segment, $filename); |
| 412 | 412 | if (empty($filename) || empty($filename[1])) { |
| 413 | 413 | continue; |
| 414 | 414 | } |
| @@ -421,8 +421,12 @@ | ||
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $extension = substr($filename, $extensionPos + 1); |
| 424 | 424 | |
| 425 | + if (!in_array(strtolower($extension), $this->allowed_extensions) || acym_isForbiddenFileExtension($filename)) { | |
| 426 | + continue; | |
| 427 | + } | |
| 428 | + | |
| 425 | 429 | // Make sure there is no double extension or space |
| 426 | 430 | $filename = preg_replace('#[^a-zA-Z0-9]#Uis', '_', substr($filename, 0, $extensionPos)); |
| 427 | 431 | |
| 428 | 432 | // Get the upload folder and create it if needed |
| @@ -437,9 +441,9 @@ | ||
| 437 | 441 | } |
| 438 | 442 | $filename = $filename.'_('.$fileNumber.')'; |
| 439 | 443 | } |
| 440 | 444 | |
| 441 | - if ($attachments && preg_match("#Content-Disposition: attachment;#i", $segment) !== false) { | |
| 445 | + if ($attachments && preg_match("#Content-Disposition: attachment;#i", $segment) === 1) { | |
| 442 | 446 | $data = trim(substr($segment, strpos($segment, "\r\n\r\n"))); |
| 443 | 447 | if (strpos($segment, 'Content-Transfer-Encoding: base64') !== false) { |
| 444 | 448 | $data = base64_decode($data); |
| 445 | 449 | } |
| @@ -610,11 +614,11 @@ | ||
| 610 | 614 | if ($extensionPos === false) { |
| 611 | 615 | return; |
| 612 | 616 | } |
| 613 | 617 | |
| 614 | - // Upload only allowed extensions in the configuration | |
| 618 | + // Upload only allowed extensions in the configuration, and never executable ones | |
| 615 | 619 | $extension = substr($filename, $extensionPos + 1); |
| 616 | - if (!in_array(strtolower($extension), $this->allowed_extensions)) { | |
| 620 | + if (!in_array(strtolower($extension), $this->allowed_extensions) || acym_isForbiddenFileExtension($filename)) { | |
| 617 | 621 | return; |
| 618 | 622 | } |
| 619 | 623 | |
| 620 | 624 | // Make sure there is no double extension or space |