mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +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;
|
$this->sValue = $sValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function CreateFromParameterLine(string $sRawParam) : self
|
public static function FromString(string $sRawParam) : self
|
||||||
{
|
{
|
||||||
$oParameter = new self('', '');
|
$oParameter = new self('', '');
|
||||||
return $oParameter->Parse($sRawParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Reset() : self
|
$aParts = \explode('=', $sRawParam, 2);
|
||||||
{
|
$oParameter->sName = \trim(\trim($aParts[0]), '"\'');
|
||||||
$this->sName = '';
|
if (2 === \count($aParts)) {
|
||||||
$this->sValue = '';
|
$oParameter->sValue = \trim(\trim($aParts[1]), '"\'');
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $oParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Name() : string
|
public function Name() : string
|
||||||
|
|
@ -56,20 +55,6 @@ class Parameter implements \JsonSerializable
|
||||||
$this->sValue = $sValue;
|
$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
|
public function ToString(bool $bConvertSpecialsName = false) : string
|
||||||
{
|
{
|
||||||
if (!\strlen($this->sName)) {
|
if (!\strlen($this->sName)) {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
||||||
$aDataToParse = \explode(';', $sRawParams);
|
$aDataToParse = \explode(';', $sRawParams);
|
||||||
|
|
||||||
foreach ($aDataToParse as $sParam) {
|
foreach ($aDataToParse as $sParam) {
|
||||||
$this->append(Parameter::CreateFromParameterLine($sParam));
|
$this->append(Parameter::FromString($sParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->reParseParameters();
|
$this->reParseParameters();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue