Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attachments with longs names are not being processed #29

Open
wants to merge 1 commit into
base: 2.10.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/Decode.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,26 @@ public static function splitHeaderField($field, $wantedPart = null, $firstName =
throw new Exception\RuntimeException('not a valid header field');
}

$fullField = [];
if ($wantedPart) {
foreach ($matches[1] as $key => $name) {
if (strcasecmp($name, $wantedPart)) {

if (!preg_match('/' . preg_quote($wantedPart) . "(\*[0-9])*" . '/', $name)) { //support multiname
continue;
}
if ($matches[2][$key][0] !== '"') {
return $matches[2][$key];

$val = $matches[2][$key][0] != '"' ? $matches[2][$key] : substr($matches[2][$key], 1, -1);

// if name and wantedPart doees not match fully(they have matched above in the regex),
// it means that we have multiple values
if (strcasecmp($name, $wantedPart) && gettype($val) === 'string') {
$fullField[$wantedPart] .= $val;
} else {// name and wantedPart match
return $val;
}
return substr($matches[2][$key], 1, -1);

}
return;
return $fullField[$wantedPart] ?: null;
}

$split = [];
Expand Down