From caf84064df23bd66e30005e61baa83c2f384a282 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?=
 <jean-philippe.guerard@tigreraye.org>
Date: Wed, 18 Jan 2012 00:51:23 +0100
Subject: [PATCH] Fix last header line size calculation

The "From: " prefix size was not taken into accounts when
calculating how many characters were on the last header line
produced by mb_encode_mimeheader.

This is used to check if the e-mail address should be
placed on a separate line.
---
 fonctions.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fonctions.php b/fonctions.php
index 99ea6418..059d6391 100644
--- a/fonctions.php
+++ b/fonctions.php
@@ -172,10 +172,10 @@ function sendEmail( $to, $subject, $body, $headers, $param)
   $subject = mb_encode_mimeheader( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ), "UTF-8", "B", "\n", 9 ) ;
 
   $encoded_app = mb_encode_mimeheader( NOMAPPLICATION, "UTF-8", "B", "\n", 6 ) ;
-  $size_encoded_app = strlen( $encoded_app ) % 75 ;
+  $size_encoded_app = ( 6 + strlen( $encoded_app ) ) % 75 ;
   $size_admin_email = strlen( ADRESSEMAILADMIN ) ;
 
-  if ( $size_encoded_app + $size_admin_email + 9 > 74 ) {
+  if ( ( $size_encoded_app + $size_admin_email + 9 ) > 74 ) {
     $folding = "\n" ;
   } else {
     $folding = "" ;
-- 
GitLab