(trunk libT) #3969 "tr_base64_encode() has unnecessary overhead with linefeeds" -- fixed.
Don't add linefeeds to base64-encoded data. We don't need it and it just increases the length of the string, which is typically sent over the network to an RPC client.
This commit is contained in:
parent
9ed800c45a
commit
392df7ceb8
|
@ -417,8 +417,8 @@ main( void )
|
||||||
/* base64 */
|
/* base64 */
|
||||||
out = tr_base64_encode( "YOYO!", -1, &len );
|
out = tr_base64_encode( "YOYO!", -1, &len );
|
||||||
check( out );
|
check( out );
|
||||||
check( !strcmp( out, "WU9ZTyE=\n" ) );
|
check( !strcmp( out, "WU9ZTyE=" ) );
|
||||||
check( len == 9 );
|
check( len == 8 );
|
||||||
in = tr_base64_decode( out, -1, &len );
|
in = tr_base64_decode( out, -1, &len );
|
||||||
check( in );
|
check( in );
|
||||||
check( !strcmp( in, "YOYO!" ) );
|
check( !strcmp( in, "YOYO!" ) );
|
||||||
|
|
|
@ -1154,6 +1154,7 @@ tr_base64_encode( const void * input, int length, int * setme_len )
|
||||||
|
|
||||||
bmem = BIO_new( BIO_s_mem( ) );
|
bmem = BIO_new( BIO_s_mem( ) );
|
||||||
b64 = BIO_new( BIO_f_base64( ) );
|
b64 = BIO_new( BIO_f_base64( ) );
|
||||||
|
BIO_set_flags( b64, BIO_FLAGS_BASE64_NO_NL );
|
||||||
b64 = BIO_push( b64, bmem );
|
b64 = BIO_push( b64, bmem );
|
||||||
BIO_write( b64, input, length );
|
BIO_write( b64, input, length );
|
||||||
(void) BIO_flush( b64 );
|
(void) BIO_flush( b64 );
|
||||||
|
|
Loading…
Reference in New Issue