Skip to content

Commit

Permalink
Need to add related parts in reverse order, since HTML node traversal…
Browse files Browse the repository at this point in the history
… is inside-out
  • Loading branch information
slusarz committed Mar 7, 2014
1 parent 52230a4 commit 50d8dcd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion imp/lib/Compose.php
Expand Up @@ -2617,6 +2617,11 @@ protected function _convertToRelated(Horde_Domhtml $html,
$related->setContentTypeParameter('start', $part->setContentId());
$related->addPart($part);

/* HTML iteration is from child->parent, so need to gather related
* parts and add at end after sorting to generate a more sensible
* attachment list. */
$add = array();

foreach ($html as $node) {
if (($node instanceof DOMElement) &&
$node->hasAttribute(self::RELATED_ATTR)) {
Expand All @@ -2628,14 +2633,16 @@ protected function _convertToRelated(Horde_Domhtml $html,
} else {
$related_part = $r_atc->getPart(true);
$attr = 'cid:' . $related_part->setContentId();
$related->addPart($related_part);
$add[] = $related_part;
}

$node->setAttribute($attr_name, $attr);
$node->removeAttribute(self::RELATED_ATTR);
}
}

array_map(array($related, 'addPart'), array_reverse($add));

return $related;
}

Expand Down

0 comments on commit 50d8dcd

Please sign in to comment.