Skip to content

Commit

Permalink
[mms] Fix some regressions in linked attachments behavior (Bug #13232).
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Jul 8, 2014
1 parent 60c40c7 commit a2f0ad7
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 32 deletions.
14 changes: 11 additions & 3 deletions imp/docs/CHANGES
@@ -1,6 +1,14 @@
----------
v6.2.0-git
----------
---------
v6.2.0RC2
---------

[mms] Fix some regressions in linked attachments behavior (Bug #13232).
[mjr] Fix fatal error when printing empty HTML attachments (Bug #13322).


---------
v6.2.0RC1
---------

[mms] Fix handling image attachments when added via the HTML editor Image
dialog.
Expand Down
6 changes: 4 additions & 2 deletions imp/lib/Compose/Attachment.php
Expand Up @@ -100,7 +100,6 @@ public function __construct(IMP_Compose $ob, Horde_Mime_Part $part,
$this->_uuid = strval(new Horde_Support_Uuid());

$storage = $this->storage;
$storage->forceLinked = true;
$storage->write($tmp_file, $this->getPart());
/* Need to save this information now, since it is possible that
* storage backends change their linked status based on the data
Expand All @@ -122,7 +121,10 @@ public function __get($name)
return $this->storage->link_url;

case 'storage':
return $injector->getInstance('IMP_Factory_ComposeAtc')->create(null, $this->_uuid, $this->forceLinked || $this->_linked);
$linked = $this->linked
? 'linked'
: (is_null($this->_linked) ? null : 'atc');
return $injector->getInstance('IMP_Factory_ComposeAtc')->create(null, $this->_uuid, $linked);

case 'tmpfile':
return $this->storage->getTempFile();
Expand Down
38 changes: 15 additions & 23 deletions imp/lib/Compose/Attachment/Storage/VfsLinked.php
Expand Up @@ -29,13 +29,6 @@ class IMP_Compose_Attachment_Storage_VfsLinked extends IMP_Compose_Attachment_St
/* The virtual path to use for VFS data (permanent storage). */
const VFS_LINK_ATTACH_PATH = '.horde/imp/attachments';

/**
* Force this attachment to be linked.
*
* @var boolean
*/
public $forceLinked = false;

/**
* Cached metadata information.
*
Expand Down Expand Up @@ -80,27 +73,26 @@ protected function _write($filename, Horde_Mime_Part $part)
{
global $browser, $conf;

if (!$this->forceLinked &&
(filesize($filename) < intval($conf['compose']['link_attach_threshold']))) {
if (filesize($filename) < intval($conf['compose']['link_attach_threshold'])) {
$this->_vfspath = self::VFS_ATTACH_PATH;
parent::write($filename, $part);
return;
}

parent::write($filename, $part);
parent::_write($filename, $part);

// Prevent 'jar:' attacks on Firefox. See Ticket #5892.
$type = $part->getType();
if ($browser->isBrowser('mozilla') &&
in_array(Horde_String::lower($type), array('application/java-archive', 'application/x-jar'))) {
$type = 'application/octet-stream';
}
if ($this->_vfspath !== self::VFS_ATTACH_PATH) {
// Prevent 'jar:' attacks on Firefox. See Ticket #5892.
$type = $part->getType();
if ($browser->isBrowser('mozilla') &&
in_array(Horde_String::lower($type), array('application/java-archive', 'application/x-jar'))) {
$type = 'application/octet-stream';
}

$md = $this->getMetadata();
$md->filename = $part->getName(true);
$md->time = time();
$md->type = $type;
$this->saveMetadata($md);
$md = $this->getMetadata();
$md->filename = $part->getName(true);
$md->time = time();
$md->type = $type;
$this->saveMetadata($md);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion imp/lib/Compose/LinkedAttachment.php
Expand Up @@ -85,7 +85,7 @@ public function sendData()
$browser->downloadHeaders($md->filename, $md->type, false, $data->length());

while (!$data->eof()) {
echo $data->getString(null, 8192);
echo $data->substring(0, 8192);
}
$data->close();
}
Expand Down
20 changes: 17 additions & 3 deletions imp/package.xml
Expand Up @@ -33,7 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
*
*
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -3655,16 +3655,30 @@
</release>
<release>
<version>
<release>6.2.0beta4</release>
<release>6.2.0RC1</release>
<api>6.2.0</api></version>
<stability>
<release>beta</release>
<api>beta</api></stability>
<date>2014-06-28</date>
<date>2014-07-01</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mms] Fix handling image attachments when added via the HTML editor Image dialog.
</notes>
</release>
<release>
<version>
<release>6.2.0RC2</release>
<api>6.2.0</api></version>
<stability>
<release>beta</release>
<api>beta</api></stability>
<date>2014-07-01</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mms] Fix some regressions in linked attachments behavior (Bug #13232).
* [mjr] Fix fatal error when printing empty HTML attachments (Bug #13322).
</notes>
</release>
</changelog>
</package>

0 comments on commit a2f0ad7

Please sign in to comment.