1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-29 03:17:53 -04:00

[data] base64 decoded not encoded. Refs #67

This commit is contained in:
Witold Filipczyk 2020-09-14 23:01:03 +02:00
parent 0fe637a4fa
commit 3d78cd1264
2 changed files with 5 additions and 4 deletions

View File

@ -118,6 +118,7 @@ data_protocol_handler(struct connection *conn)
struct cache_entry *cached = get_cache_entry(uri);
unsigned char *data_start, *data;
int base64 = 0;
int datalen = 0;
if (!cached) {
abort_connection(conn, connection_state(S_OUT_OF_MEM));
@ -141,7 +142,7 @@ data_protocol_handler(struct connection *conn)
}
if (base64) {
unsigned char *decoded = base64_encode(data);
unsigned char *decoded = base64_decode_bin(data, strlen(data), &datalen);
if (!decoded) {
abort_connection(conn, connection_state(S_OUT_OF_MEM));
@ -155,7 +156,7 @@ data_protocol_handler(struct connection *conn)
{
/* Use strlen() to get the correct decoded length */
int datalen = strlen(data);
if (!datalen) datalen = strlen(data);
add_fragment(cached, conn->from, data, datalen);
conn->from += datalen;

View File

@ -63,9 +63,9 @@ base64_encode_bin(register unsigned char *in, int inlen, int *outlen)
return outstr;
}
/* Base64 decoding is used only with the CONFIG_FORMHIST or CONFIG_GSSAPI
/* Base64 decoding is used only with the CONFIG_FORMHIST, CONFIG_GSSAPI or CONFIG_DATA
feature, so i'll #ifdef it */
#if defined(CONFIG_FORMHIST) || defined(CONFIG_GSSAPI)
#if defined(CONFIG_FORMHIST) || defined(CONFIG_GSSAPI) || defined(CONFIG_DATA)
unsigned char *
base64_decode(register unsigned char *in)