Aleksander Machniak
2013-03-15 4c0c248dd9eb2f928a8e2468927307b2c8dbc375
program/lib/Roundcube/rcube_message.php
@@ -93,7 +93,7 @@
        $this->subject = $this->mime->decode_mime_string($this->headers->subject);
        list(, $this->sender) = each($this->mime->decode_address_list($this->headers->from, 1));
        $this->set_safe((intval($_GET['_safe']) || $_SESSION['safe_messages'][$uid]));
        $this->set_safe((intval($_GET['_safe']) || $_SESSION['safe_messages'][$this->folder.':'.$uid]));
        $this->opt = array(
            'safe' => $this->is_safe,
            'prefer_html' => $this->app->config->get('prefer_html'),
@@ -144,8 +144,7 @@
     */
    public function set_safe($safe = true)
    {
        $this->is_safe = $safe;
        $_SESSION['safe_messages'][$this->uid] = $this->is_safe;
        $_SESSION['safe_messages'][$this->folder.':'.$this->uid] = $this->is_safe = $safe;
    }
@@ -210,18 +209,20 @@
                if (!$recursive) {
                    $level = explode('.', $part->mime_id);
                    // Skip if level too deep or part has a file name
                    if (count($level) > 2 || $part->filename) {
                    // Skip if part is an attachment
                    if ($this->is_attachment($part)) {
                        continue;
                    }
                    // HTML part can be on the lower level, if not...
                    if (count($level) > 1) {
                        array_pop($level);
                    // Check if the part belongs to higher-level's alternative/related
                    while (array_pop($level) !== null) {
                        if (!count($level)) {
                            return true;
                        }
                        $parent = $this->mime_parts[join('.', $level)];
                        // ... parent isn't multipart/alternative or related
                        if ($parent->mimetype != 'multipart/alternative' && $parent->mimetype != 'multipart/related') {
                            continue;
                            continue 2;
                        }
                    }
                }
@@ -468,6 +469,17 @@
            $this->parts[] = $p;
        }
        // this is an S/MIME ecrypted message -> create a plaintext body with the according message
        else if ($mimetype == 'application/pkcs7-mime') {
            $p = new stdClass;
            $p->type            = 'content';
            $p->ctype_primary   = 'text';
            $p->ctype_secondary = 'plain';
            $p->mimetype        = 'text/plain';
            $p->realtype        = 'application/pkcs7-mime';
            $this->parts[] = $p;
        }
        // message contains multiple parts
        else if (is_array($structure->parts) && !empty($structure->parts)) {
            // iterate over parts