Base 64 detection improvement

Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
Tyrolyean 2020-04-29 20:18:10 +02:00
parent c5257bbb6c
commit b1ef07c103
No known key found for this signature in database
GPG Key ID: 81EC9BAC5E9667C6
5 changed files with 18 additions and 7 deletions

View File

@ -49,6 +49,11 @@ struct email_t{
size_t ct_len;
char* content_type;
/* NOTICE: the boundary, content_type and message fields may be updated
* when the message of the root object is modified. See the
* propagate_root_pointer function for further information
*/
size_t submes_cnt;
struct email_t** submes;
struct email_t* parent;
@ -64,6 +69,9 @@ void propagate_insert_delete(struct email_t* mail, char* change_p,
ssize_t change);
void propagate_root_pointer(struct email_t* mail, char* change_p, char* old_p);
struct type_file_info_t{
};
#define MULTIPART_MIME "multipart/"
#define BASE64_ENC "base64"

View File

@ -29,8 +29,8 @@ char* search_header_key(const struct email_t* mail, const char* key);
char* get_value_from_key(size_t* val_len, size_t key_offset,
const struct email_t* mail);
char* get_multipart_boundary(char* content_type, size_t content_len,
size_t* boundary_len);
char* get_value_equals(char* content_type, size_t content_len,
size_t* boundary_len, char* key);
const char* get_next_line(const char* message, size_t len);
const char* get_prev_line(const char* message, size_t len_neg);

View File

@ -77,8 +77,9 @@ struct email_t* mail_from_text(char* message, size_t length,
*/
mail->is_multipart = true;
size_t bd_len = 0;
char* bd = get_multipart_boundary(
mime_type, value_length, &bd_len);
char* bd = get_value_equals(
mime_type, value_length, &bd_len,
"boundary");
if(bd != NULL){
mail->boundary = bd;

View File

@ -168,3 +168,5 @@ void propagate_root_pointer(struct email_t* mail, char* change_p, char* old_p){
return;
}

View File

@ -119,14 +119,14 @@ char* get_value_from_key(size_t* val_len, size_t key_offset,
return val;
}
char* get_multipart_boundary(char* content_type, size_t content_len,
size_t* boundary_len){
char* get_value_equals(char* content_type, size_t content_len,
size_t* boundary_len, char* key){
if(content_type == NULL || boundary_len == NULL){
return NULL;
}
char* bd = "boundary";
char* bd = key;
char* boundary_begin = NULL;
size_t bd_len = strlen(bd);
long boundary_offset = -1;