Avoid saving attachments with empty mimetype; validate before adding to XML (#2927)

This commit is contained in:
Thomas Bruederli 2014-03-18 10:11:00 +01:00
parent 621582307f
commit 2dec4c3e6e

View file

@ -531,8 +531,19 @@ abstract class kolab_format
continue;
$attach = new Attachment;
$attach->setLabel((string)$attr['name']);
$attach->setUri('cid:' . $cid, $attr['mimetype']);
$vattach->push($attach);
$attach->setUri('cid:' . $cid, $attr['mimetype'] ?: 'application/octet-stream');
if ($attach->isValid()) {
$vattach->push($attach);
}
else {
rcube::raise_error(array(
'code' => 660,
'type' => 'php',
'file' => __FILE__,
'line' => __LINE__,
'message' => "Invalid attributes for attachment $cid: " . var_export($attr, true),
), true);
}
}
foreach ((array) $object['links'] as $link) {