[BUG] GPG encrypted data gets corrupted

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
furax
Forum Newbie
Posts: 3
Joined: Thu Aug 09, 2007 5:55 am

[BUG] GPG encrypted data gets corrupted

Post by furax »

I have found that the function encode8Bit (and others I guess) in Encoder.php (line 315) messes an ordinary GPG encrypted text so it becomes unreadable by the recipient.

I have noticed that on such data, the wordwrap function should not be used after the fixLE function. Si I have changed th function to:

Code: Select all

public function encode8Bit($data, $chunk=76, $le="\r\n")
  {
    if(strpos($data, "-----BEGIN PGP MESSAGE-----") === 0)
    	return $this->fixLE($data,$le);
    else
    	return $this->fixLE(wordwrap($data, $chunk-2, $le, 1), $le);
  }
But there must be a better way to handle the situation...

All the best, end thanks for such a great work !
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Turn line wrapping off:

Code: Select all

$message->setLineWrap(0);
If you have any MIME parts embedded you also need to run:

Code: Select all

$part->setLineWrap(0);
furax
Forum Newbie
Posts: 3
Joined: Thu Aug 09, 2007 5:55 am

Post by furax »

d11wtq wrote:Turn line wrapping off:

Code: Select all

$message->setLineWrap(0);
Ahem... this puts one caracter per line in the mail, not quite what we want, do we :( ?

Could that be because the "cut" parameter of the wordwrap function is forced to 1 ?
furax
Forum Newbie
Posts: 3
Joined: Thu Aug 09, 2007 5:55 am

Post by furax »

furax wrote:
d11wtq wrote:Turn line wrapping off:

Code: Select all

$message->setLineWrap(0);
Ahem... this puts one caracter per line in the mail, not quite what we want, do we :( ?

Could that be because the "cut" parameter of the wordwrap function is forced to 1 ?
No, found it !

It's because the $chunk-2 in the encoding function... so you need setLineWrap(2)...

But then, PHP throws an error because of the forced cut:
Can't force cut when width is zero
That being said, the result is still not satisfactory with the with at 0 and the cut unset as blank lines are added...
Post Reply