Charset now an optional string.
This commit is contained in:
11
src/cache.cc
11
src/cache.cc
@ -493,7 +493,8 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
|
||||
const char *from)
|
||||
{
|
||||
const char *curr;
|
||||
char *major, *minor, *charset;
|
||||
char *major, *minor;
|
||||
std::optional< std::string > charset;
|
||||
CacheEntry_t *entry = Cache_entry_search(url);
|
||||
|
||||
dReturn_val_if_fail (entry != NULL, NULL);
|
||||
@ -514,7 +515,7 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
|
||||
}
|
||||
if (a_Misc_content_type_cmp(curr, ctype)) {
|
||||
/* ctype gives one different from current */
|
||||
a_Misc_parse_content_type(ctype, &major, &minor, &charset);
|
||||
charset= a_Misc_parse_content_type(ctype, &major, &minor);
|
||||
if (*from == 'm' && charset &&
|
||||
((!major || !*major) && (!minor || !*minor))) {
|
||||
/* META only gives charset; use detected MIME type too */
|
||||
@ -524,7 +525,7 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
|
||||
/* WORKAROUND: doxygen uses "text/xhtml" in META */
|
||||
if (charset) {
|
||||
entry->TypeNorm = dStrconcat("application/xhtml+xml",
|
||||
"; charset=", charset, NULL);
|
||||
"; charset=", charset.value().c_str(), NULL);
|
||||
} else {
|
||||
entry->TypeNorm = dStrdup("application/xhtml+xml");
|
||||
}
|
||||
@ -532,14 +533,14 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
|
||||
if (charset) {
|
||||
if (entry->CharsetDecoder)
|
||||
a_Decode_free(entry->CharsetDecoder);
|
||||
entry->CharsetDecoder = a_Decode_charset_init(charset);
|
||||
entry->CharsetDecoder = a_Decode_charset_init(charset.value().c_str());
|
||||
curr = Cache_current_content_type(entry);
|
||||
|
||||
/* Invalidate UTF8Data */
|
||||
dStr_free(entry->UTF8Data, 1);
|
||||
entry->UTF8Data = NULL;
|
||||
}
|
||||
dFree(major); dFree(minor); dFree(charset);
|
||||
dFree(major); dFree(minor);
|
||||
}
|
||||
}
|
||||
return curr;
|
||||
|
||||
Reference in New Issue
Block a user