Skip to content

Commit

Permalink
Comments, now that it works.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Oct 17, 2023
1 parent 5dd8a96 commit 79aea1d
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions lib/Horde/Mime/Headers/ThreadIndex.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
<?php
/**
* Copyright 2023 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2023 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Mime
*/

/**
* This class represents the (non-standard) ThreadIndex header sent by
* the desktop MS Outlook products.
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @category Horde
* @copyright 2023 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Mime
*/
class Horde_Mime_Headers_ThreadIndex extends Horde_Mime_Headers_Element_Single
{
Expand All @@ -18,12 +37,19 @@ public static function getHandles()
*/
protected function _sendEncode($opts)
{
// First try to encode it the standard way. This
// will catch any cases where the header may not contain
// the expected base64 encoded string, but rather some
// other data that would normally get encoded.
$encoded = Horde_Mime::encode($this->value, $opts['charset']);

if ($encoded != $this->value) {
return array($this->value);
}

// We didn't encode it already, check for extra-long
// headers that exceed the 998 character maximum imposed
// by RFC 2045. The above encoding would not normally catch
// this sicne the expected data does not contain any whitespace.
$len = strlen($this->value);
$crlf = 0;
$needs_encoding = false;
Expand All @@ -32,7 +58,8 @@ protected function _sendEncode($opts)
switch ($chr) {
case 0:
// NULLs not valid here, should have
// been caught above.
// been caught above. Just nuke the header
// in this case, it's broken.
return array('');
case 10:
case 13:
Expand All @@ -47,6 +74,8 @@ protected function _sendEncode($opts)
}
}

// If we need encoding, encode it with RFC 2045 mime encoding
// then fold the resulting lines.
if ($needs_encoding) {
$delim = '=?' . $opts['charset'] . '?b?';
$parts = explode(
Expand Down

0 comments on commit 79aea1d

Please sign in to comment.