Skip to content

Commit 0e5e6f2

Browse files
committed
Missing variable check added to prevent part subtype parsing error Webklex#27
1 parent 624dc77 commit 0e5e6f2

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Part.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected function parse(){
166166
$body = $this->raw;
167167
}
168168

169-
$this->parseSubtype();
169+
$this->subtype = $this->parseSubtype($this->header->get("content-type"));
170170
$this->parseDisposition();
171171
$this->parseDescription();
172172
$this->parseEncoding();
@@ -218,12 +218,23 @@ private function findHeaders(){
218218

219219
/**
220220
* Try to parse the subtype if any is present
221+
* @param $content_type
222+
*
223+
* @return string
221224
*/
222-
private function parseSubtype(){
223-
$content_type = $this->header->get("content-type");
225+
private function parseSubtype($content_type){
226+
if (is_array($content_type)) {
227+
foreach ($content_type as $part){
228+
if ((strpos($part, "/")) !== false){
229+
return $this->parseSubtype($part);
230+
}
231+
}
232+
return null;
233+
}
224234
if (($pos = strpos($content_type, "/")) !== false){
225-
$this->subtype = substr($content_type, $pos + 1);
235+
return substr($content_type, $pos + 1);
226236
}
237+
return null;
227238
}
228239

229240
/**

0 commit comments

Comments
 (0)