text stringlengths 0 357 |
|---|
quote_words = 1; |
end = cur; |
} |
else { |
break; |
} |
if (* cur != '\0') { |
cur ++; |
} |
} |
if (quote_words) |
{ |
if ( !quote_word(DEF_DISPLAY_CHARSET, mmapstr, begin, end - begin)) { |
goto cleanup; |
} |
if ((* end==' ') || (* end=='\t')) { |
if (mmap_string_append_c(mmapstr, * end)==0) { |
goto cleanup; |
} |
end ++; |
} |
if (* end != '\0') { |
if (mmap_string_append_len(mmapstr, end, cur - end)==NULL) { |
goto cleanup; |
} |
} |
} |
else |
{ |
if (mmap_string_append_len(mmapstr, begin, cur - begin)==NULL) { |
goto cleanup; |
} |
} |
if ((* cur==' ') || (* cur=='\t')) { |
if (mmap_string_append_c(mmapstr, * cur)==0) { |
goto cleanup; |
} |
cur ++; |
} |
} |
ret_str = strdup(mmapstr->str); |
cleanup: |
if (mmapstr) { |
mmap_string_free(mmapstr); |
} |
return ret_str; |
} |
/** |
* Decode non-ascii-strings as `=?UTF-8?Q?Bj=c3=b6rn_Petersen?=`. |
* Belongs to RFC 2047: https://tools.ietf.org/html/rfc2047 |
* |
* @param in String to decode. |
* @return Returns the null-terminated decoded string as UTF-8. Must be free()'d when no longed needed. |
* On errors, NULL is returned. |
*/ |
char* dc_decode_header_words(const char* in) |
{ |
/* decode strings as. `=?UTF-8?Q?Bj=c3=b6rn_Petersen?=`) |
if `in` is NULL, `out` is NULL as well; also returns NULL on errors */ |
if (in==NULL) { |
return NULL; /* no string given */ |
} |
char* out = NULL; |
size_t cur_token = 0; |
int r = mailmime_encoded_phrase_parse(DEF_INCOMING_CHARSET, in, strlen(in), &cur_token, DEF_DISPLAY_CHARSET, &out); |
if (r != MAILIMF_NO_ERROR || out==NULL) { |
out = dc_strdup(in); /* error, make a copy of the original string (as we free it later) */ |
} |
return out; /* must be free()'d by the caller */ |
} |
/******************************************************************************* |
* Encode/decode modified UTF-7 as needed for IMAP, see RFC 2192 |
******************************************************************************/ |
// UTF7 modified base64 alphabet |
static const char base64chars[] = |
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; |
/** |
* Convert an UTF-8 string to a modified UTF-7 string |
* that is needed eg. for IMAP mailbox names. |
* |
* Example: `Björn Petersen` gets encoded to `Bj&APY-rn_Petersen` |
* |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.