diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2009-02-15 16:04:56 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2009-02-15 16:04:56 -0300 |
commit | 14f136096ca28cba15da7521c798e27327f357d7 (patch) | |
tree | 986b4ccec042c21cf6dfdc04eb835c401415678d | |
parent | 21ab6086012d25b3093b5da4407b9c8708ff416b (diff) |
Fixed handling of META's content-type with no MIME type (e.g. only charset).
e.g. some links at http://git.kernel.org/gitweb.cgi didn't render.
e.g. #2 This page didn't render:
<html>
<head>
<meta http-equiv="content-type" content="; charset=utf-8"/>
<title></title>
</head>
<body>
Generating....
</body>
</html>
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/cache.c | 22 | ||||
-rw-r--r-- | src/html.cc | 7 | ||||
-rw-r--r-- | src/nav.c | 2 |
4 files changed, 21 insertions, 11 deletions
@@ -69,6 +69,7 @@ dillo-2.1 - Removed the nav.h dependency from html.cc - Made the repush() operation more general and suited for CSS use. - Fixed collapsing of whitespace entities in HTML mode. + - Fixed handling of META's content-type with no MIME type (e.g. only charset). Patches: Jorge Arellano Cid dw diff --git a/src/cache.c b/src/cache.c index e634b337..48e278f6 100644 --- a/src/cache.c +++ b/src/cache.c @@ -53,6 +53,7 @@ typedef struct { char *TypeDet; /* MIME type string (detected from data) */ char *TypeHdr; /* MIME type string as from the HTTP Header */ char *TypeMeta; /* MIME type string from META HTTP-EQUIV */ + char *TypeNorm; /* MIME type string normalized */ Dstr *Header; /* HTTP header */ const DilloUrl *Location; /* New URI for redirects */ Dlist *Auth; /* Authentication fields */ @@ -208,6 +209,7 @@ static void Cache_entry_init(CacheEntry_t *NewEntry, const DilloUrl *Url) NewEntry->TypeDet = NULL; NewEntry->TypeHdr = NULL; NewEntry->TypeMeta = NULL; + NewEntry->TypeNorm = NULL; NewEntry->Header = dStr_new(""); NewEntry->Location = NULL; NewEntry->Auth = NULL; @@ -313,6 +315,7 @@ static void Cache_entry_free(CacheEntry_t *entry) dFree(entry->TypeDet); dFree(entry->TypeHdr); dFree(entry->TypeMeta); + dFree(entry->TypeNorm); dStr_free(entry->Header, TRUE); a_Url_free((DilloUrl *)entry->Location); Cache_auth_free(entry->Auth); @@ -460,8 +463,8 @@ static void Cache_unref_data(CacheEntry_t *entry) */ static const char *Cache_current_content_type(CacheEntry_t *entry) { - return entry->TypeMeta ? entry->TypeMeta : entry->TypeHdr ? entry->TypeHdr : - entry->TypeDet; + return entry->TypeNorm ? entry->TypeNorm : entry->TypeMeta ? entry->TypeMeta + : entry->TypeHdr ? entry->TypeHdr : entry->TypeDet; } /* @@ -490,8 +493,8 @@ static Dstr *Cache_data(CacheEntry_t *entry) const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype, const char *from) { - char *charset; const char *curr; + char *major, *minor, *charset; CacheEntry_t *entry = Cache_entry_search_with_redirect(url); dReturn_val_if_fail (entry != NULL, NULL); @@ -512,7 +515,12 @@ 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, NULL, NULL, &charset); + a_Misc_parse_content_type(ctype, &major, &minor, &charset); + if (*from == 'm' && charset && + ((!major || !*major) && (!minor || !*minor))) { + /* META only gives charset; use detected MIME type too */ + entry->TypeNorm = dStrconcat(entry->TypeDet, ctype, NULL); + } if (charset) { if (entry->CharsetDecoder) a_Decode_free(entry->CharsetDecoder); @@ -1111,13 +1119,13 @@ static void Cache_process_queue(CacheEntry_t *entry) if (TypeMismatch) { AbortEntry = TRUE; } else { - const char *content_type = Cache_current_content_type(entry); - st = a_Web_dispatch_by_type(content_type, ClientWeb, + const char *curr_type = Cache_current_content_type(entry); + st = a_Web_dispatch_by_type(curr_type, ClientWeb, &Client->Callback, &Client->CbData); if (st == -1) { /* MIME type is not viewable */ if (ClientWeb->flags & WEB_RootUrl) { - MSG("Content-Type '%s' not viewable.\n", content_type); + MSG("Content-Type '%s' not viewable.\n", curr_type); /* prepare a download offer... */ AbortEntry = OfferDownload = TRUE; } else { diff --git a/src/html.cc b/src/html.cc index 64064d6a..bbf49bd4 100644 --- a/src/html.cc +++ b/src/html.cc @@ -2792,12 +2792,13 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize) ds_msg = dStr_sized_new(256); dStr_sprintf(ds_msg, meta_template, content, delay_str); { - int SaveFlags = html->InFlags; + int o_InFlags = html->InFlags; + int o_TagSoup = html->TagSoup; html->InFlags = IN_BODY; html->TagSoup = false; Html_write_raw(html, ds_msg->str, ds_msg->len, 0); - html->TagSoup = true; - html->InFlags = SaveFlags; + html->TagSoup = o_TagSoup; + html->InFlags = o_InFlags; } dStr_free(ds_msg, 1); @@ -368,7 +368,7 @@ static void Nav_repush(BrowserWindow *bw) static void Nav_repush_callback(void *data) { - _MSG(">>> Nav_repush_callback <<<<\n"); + _MSG(">>>> Nav_repush_callback <<<<\n"); Nav_repush(data); a_Timeout_remove(); } |