From 87eeca570f178e83bc47f1864242a824051d1fd8 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Fri, 10 Sep 2010 13:19:19 +0800 Subject: [PATCH] Fix outlook can't get correct attachment send by TortoiseGit-1.5.3.0-32bit.msi Need \n at 80 column when Base64 convert to text Signed-off-by: Frank Li --- src/Utils/CBase64.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Utils/CBase64.cpp b/src/Utils/CBase64.cpp index dfde493fc..9bdcb9df9 100644 --- a/src/Utils/CBase64.cpp +++ b/src/Utils/CBase64.cpp @@ -40,6 +40,7 @@ CStringA CBase64::Encode( IN const char* szEncoding, IN int nSize ) int nNumBits = 6; UINT nDigit; int lp = 0; + int count = 0; ASSERT( szEncoding != NULL ); if( szEncoding == NULL ) @@ -53,6 +54,10 @@ CStringA CBase64::Encode( IN const char* szEncoding, IN int nSize ) { sOutput += m_sBase64Alphabet[ (int)nDigit ]; nDigit = read_bits( nNumBits, &nNumBits, lp ); + count++; + + if(count % 80 == 0) + sOutput += '\n'; } // Pad with '=' as per RFC 1521 while( sOutput.GetLength() % 4 != 0 ) @@ -92,6 +97,8 @@ int CBase64::Decode ( IN const char* szDecoding, char* szOutput ) { nDecode[ m_sBase64Alphabet[ i ] ] = i; nDecode[ m_sBase64Alphabet[ i ] | 0x80 ] = i; // Ignore 8th bit + nDecode[ '\r' ] = -1; + nDecode[ '\n' ] = -1; nDecode[ '=' ] = -1; nDecode[ '=' | 0x80 ] = -1; // Ignore MIME padding char } -- 2.11.4.GIT