Skip to content

Commit

Permalink
Improve parts boundary detection in Webklex/php-imap - closes #4417
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Dec 12, 2024
1 parent 0e14e08 commit 13bf220
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions overrides/webklex/php-imap/src/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,20 @@ public function find($pattern) {
* @return string|null
*/
public function getBoundary() {
$regex = $this->config["boundary"] ?? "/boundary=(.*?(?=;)|(.*))/i";
$boundary = $this->find($regex);
// Finding boundary via regex is not 100% reliable as boundary
// may be mentioned in other headers.
$boundary = null;
if (is_object($this->boundary)) {
$values = $this->boundary->get();
if (!empty($values[0])) {
$boundary = $values[0];
}
}

if (!$boundary) {
$regex = $this->config["boundary"] ?? "/boundary=(.*?(?=;)|(.*))/i";
$boundary = $this->find($regex);
}

if ($boundary === null) {
return null;
Expand Down

0 comments on commit 13bf220

Please sign in to comment.