Skip to content

Commit

Permalink
Missing variable check added to prevent content-type parsing error #356
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Oct 16, 2020
1 parent 0e5e6f2 commit c8051a5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ protected function parse(){
$body = $this->raw;
}

$this->subtype = $this->parseSubtype($this->header->get("content-type"));
$this->parseDisposition();
$this->parseDescription();
$this->parseEncoding();
Expand All @@ -186,10 +185,15 @@ protected function parse(){
]);
}

if(!empty($this->header->get("content-type"))){
$rawContentType = $this->header->get("content-type");
$contentTypeArray = explode(';', $rawContentType);
$this->content_type = trim($contentTypeArray[0]);
$content_types = $this->header->get("content-type");
if(!empty($content_types)){
$this->subtype = $this->parseSubtype($content_types);
$content_type = $content_types;
if (is_array($content_types)) {
$content_type = $content_types[0];
}
$parts = explode(';', $content_type);
$this->content_type = trim($parts[0]);
}


Expand Down

0 comments on commit c8051a5

Please sign in to comment.