Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .horde.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ dependencies:
php: ^7.4 || ^8
composer:
horde/exception: ^3
horde/listheaders: ^2
horde/mail: ^3
horde/stream: ^2
horde/stream_filter: ^3
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"minimum-stability": "dev",
"name": "horde/mime",
"description": "MIME library",
"type": "library",
Expand All @@ -21,7 +22,6 @@
"require": {
"php": "^7.4 || ^8",
"horde/exception": "^3 || dev-FRAMEWORK_6_0",
"horde/listheaders": "^2 || dev-FRAMEWORK_6_0",
"horde/mail": "^3 || dev-FRAMEWORK_6_0",
"horde/stream": "^2 || dev-FRAMEWORK_6_0",
"horde/stream_filter": "^3 || dev-FRAMEWORK_6_0",
Expand Down
100 changes: 71 additions & 29 deletions lib/Horde/Mime/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class Horde_Mime_Headers implements ArrayAccess, IteratorAggregate, Serializable
*/
protected $_headers;

/**
* The EOL string to use for output.
*
* @var string
*/
protected $_eol = "\n";

/**
* Constructor.
*/
Expand Down Expand Up @@ -512,50 +519,85 @@ public function getIterator()
return new ArrayIterator($this->_headers);
}

/* Deprecated functions */
/* Header value access */

/**
* Handle deprecated methods.
*/
public function __call($name, $arguments)
{
$d = new Horde_Mime_Headers_Deprecated($this);
return call_user_func_array([$d, $name], $arguments);
}
/* Constants for getValue(). */
public const VALUE_STRING = 1;
public const VALUE_BASE = 2;
public const VALUE_PARAMS = 3;

/**
* Handle deprecated static methods.
* Get a header value in a specific format.
*
* @param string $header Header name.
* @param int $type VALUE_STRING (full value), VALUE_BASE (base
* value), or VALUE_PARAMS (parameters only).
*
* @return mixed Header value, or null if not found.
*/
public static function __callStatic($name, $arguments)
public function getValue($header, $type = self::VALUE_STRING)
{
$d = new Horde_Mime_Headers_Deprecated(new Horde_Mime_Headers());
return call_user_func_array([$d, $name], $arguments);
}
if (!($ob = $this[$header])) {
return null;
}

/**
* @deprecated
*/
protected $_eol = "\n";
switch ($type) {
case self::VALUE_BASE:
$tmp = $ob->value;
break;

case self::VALUE_PARAMS:
return array_change_key_case($ob->params, CASE_LOWER);

case self::VALUE_STRING:
$tmp = $ob->full_value;
break;
}

return (is_array($tmp) && (count($tmp) === 1))
? reset($tmp)
: $tmp;
}

/**
* @deprecated
* Replace a header value.
*
* @param string $header Header name.
* @param string $value Header value.
* @param array $opts Additional options passed to addHeader().
*/
public function setEOL($eol)
public function replaceHeader($header, $value, array $opts = [])
{
$this->_eol = $eol;
$this->removeHeader($header);
$this->addHeader($header, $value, $opts);
}

/**
* @deprecated
* Return the list of single-value header fields.
*
* @param bool $list Include list header fields?
*
* @return array List of single-value header field names (lowercase).
*/
public function getEOL()
public function singleFields($list = true)
{
return $this->_eol;
}
$fields = [
'to', 'from', 'cc', 'bcc', 'date', 'sender', 'reply-to',
'message-id', 'in-reply-to', 'references', 'subject',
'content-md5', 'mime-version', 'content-type',
'content-transfer-encoding', 'content-id', 'content-description',
'content-base', 'content-disposition', 'content-duration',
'content-location', 'content-features', 'content-language',
'content-alternative', 'importance', 'x-priority',
];

/* Constants for getValue(). @deprecated */
public const VALUE_STRING = 1;
public const VALUE_BASE = 2;
public const VALUE_PARAMS = 3;
$list_fields = [
'list-help', 'list-unsubscribe', 'list-subscribe', 'list-owner',
'list-post', 'list-archive', 'list-id',
];

return $list
? array_merge($fields, $list_fields)
: $fields;
}
}
Loading
Loading