From: stekkel Date: Thu, 24 Jul 2003 18:08:10 +0000 (+0000) Subject: Correct on the fly base64 decode algoritm in case the returned data does not X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=0c22ec3cd4cfc764bc270f826351a3b2b60b6766 Correct on the fly base64 decode algoritm in case the returned data does not have "proper" lines with the same length. With an old uw server I discovered that lines were split in the middle by \n. This fix will correct it. The rfc about base64 decoding does not mention anything about line length. rfc2045 does mention that lines should not be longer then 78 characters but does not say all the lines (excluding the last of course) must be of the same size. There for i could not ignore it and fixed it. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5415 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/imap_general.php b/functions/imap_general.php index 63d37823..4ac6d3ea 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -201,6 +201,17 @@ function sqimap_fread($imap_stream,$iSize,$filter=false, break; } $iRetrieved += $iBufferSize; + // if the returned lines are split, do not end with \n + // then we have a problem and need to adjust (happened with uw) + if ($bBufferSizeAdapted && substr($sRead,-1) !== "\n") { + // use fgets because it stops at \n. + // we can do it because it's for correction + $sRead .= fgets($imap_stream,$iBufferSize); + $iRetrieved += strlen($sRead); + if ($iRetrieved == $iSize) { + $bFinished = true; + } + } if ($filter) { // in case line-endings do not appear at position 78 we adapt the buffersize so we can base64 decode on the fly if (!$bBufferSizeAdapted) {