mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +03:00
Cleanup mime header parameter handling
This commit is contained in:
parent
5747b7add6
commit
4d9fb41d73
2 changed files with 8 additions and 23 deletions
|
|
@ -27,18 +27,17 @@ class Parameter implements \JsonSerializable
|
|||
$this->sValue = $sValue;
|
||||
}
|
||||
|
||||
public static function CreateFromParameterLine(string $sRawParam) : self
|
||||
public static function FromString(string $sRawParam) : self
|
||||
{
|
||||
$oParameter = new self('', '');
|
||||
return $oParameter->Parse($sRawParam);
|
||||
}
|
||||
|
||||
public function Reset() : self
|
||||
{
|
||||
$this->sName = '';
|
||||
$this->sValue = '';
|
||||
$aParts = \explode('=', $sRawParam, 2);
|
||||
$oParameter->sName = \trim(\trim($aParts[0]), '"\'');
|
||||
if (2 === \count($aParts)) {
|
||||
$oParameter->sValue = \trim(\trim($aParts[1]), '"\'');
|
||||
}
|
||||
|
||||
return $this;
|
||||
return $oParameter;
|
||||
}
|
||||
|
||||
public function Name() : string
|
||||
|
|
@ -56,20 +55,6 @@ class Parameter implements \JsonSerializable
|
|||
$this->sValue = $sValue;
|
||||
}
|
||||
|
||||
public function Parse(string $sRawParam, string $sSeparator = '=') : self
|
||||
{
|
||||
$this->Reset();
|
||||
|
||||
$aParts = \explode($sSeparator, $sRawParam, 2);
|
||||
|
||||
$this->sName = \trim(\trim($aParts[0]), '"\'');
|
||||
if (2 === \count($aParts)) {
|
||||
$this->sValue = \trim(\trim($aParts[1]), '"\'');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function ToString(bool $bConvertSpecialsName = false) : string
|
||||
{
|
||||
if (!\strlen($this->sName)) {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
$aDataToParse = \explode(';', $sRawParams);
|
||||
|
||||
foreach ($aDataToParse as $sParam) {
|
||||
$this->append(Parameter::CreateFromParameterLine($sParam));
|
||||
$this->append(Parameter::FromString($sParam));
|
||||
}
|
||||
|
||||
$this->reParseParameters();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue