Page Menu
Home
WMGMC Issues
搜索
Configure Global Search
登录
Files
F16277
Parameters.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
订阅
标记用于日后
授予令牌
Size
1 KB
Referenced Files
None
订阅者
None
Parameters.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Ddeboer\Imap\Message
;
/**
* @extends \ArrayIterator<int|string, int|string|\stdClass[]>
*/
class
Parameters
extends
\ArrayIterator
{
/**
* @var array<string, string>
*/
private
static
array
$attachmentCustomKeys
=
[
'name*'
=>
'name'
,
'filename*'
=>
'filename'
,
];
/**
* @param \stdClass[] $parameters
*/
public
function
add
(
array
$parameters
=
[]):
void
{
foreach
(
$parameters
as
$parameter
)
{
$key
=
\strtolower
(
$parameter
->
attribute
);
if
(
isset
(
self
::
$attachmentCustomKeys
[
$key
]))
{
$key
=
self
::
$attachmentCustomKeys
[
$key
];
}
$value
=
$this
->
decode
(
$parameter
->
value
);
$this
[
$key
]
=
$value
;
}
}
/**
* @return null|int|\stdClass[]|string
*/
public
function
get
(
string
$key
)
{
return
$this
[
$key
]
??
null
;
}
final
protected
function
decode
(
string
$value
):
string
{
$parts
=
\imap_mime_header_decode
(
$value
);
if
(!
\is_array
(
$parts
))
{
return
$value
;
}
$decoded
=
''
;
foreach
(
$parts
as
$part
)
{
$text
=
$part
->
text
;
if
(
'default'
!==
$part
->
charset
)
{
$text
=
Transcoder
::
decode
(
$text
,
$part
->
charset
);
}
// RFC2231
if
(
1
===
\preg_match
(
'/^(?<encoding>[^
\'
]+)
\'
[^
\'
]*?
\'
(?<urltext>.+)$/'
,
$text
,
$matches
))
{
$hasInvalidChars
=
1
===
\preg_match
(
'#[^%a-zA-Z0-9
\-
_
\.\+
]#'
,
$matches
[
'urltext'
]);
$hasEscapedChars
=
1
===
\preg_match
(
'#%[a-zA-Z0-9]{2}#'
,
$matches
[
'urltext'
]);
if
(!
$hasInvalidChars
&&
$hasEscapedChars
)
{
$text
=
Transcoder
::
decode
(
\urldecode
(
$matches
[
'urltext'
]),
$matches
[
'encoding'
]);
}
}
$decoded
.=
$text
;
}
return
$decoded
;
}
}
File Metadata
详情
附加的
Mime Type
text/x-php
Expires
9月 12 Fri, 3:00 AM (22 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5731
默认替代文本
Parameters.php (1 KB)
Attached To
Mode
rMAILCOW mailcow-tracking
附加的
Detach File
Event Timeline
Log In to Comment