summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2013-01-03 07:47:25 +0000
committercorvid <corvid@lavabit.com>2013-01-03 07:47:25 +0000
commit366660644ca6fb23c158db6f42a987c16a037d6d (patch)
tree87e18b3b14f3dc055d6e769caa9e899bfe40e4f7 /src
parent93e772ac635f029405443cfc1eab60a111ff83f9 (diff)
web dispatch, don't prepare for display if the content type isn't viewable
Alexander had found a problem with background color: http://lists.auriga.wearlab.de/pipermail/dillo-dev/2012-December/009710.html
Diffstat (limited to 'src')
-rw-r--r--src/IO/mime.c23
-rw-r--r--src/IO/mime.h3
-rw-r--r--src/web.cc9
3 files changed, 14 insertions, 21 deletions
diff --git a/src/IO/mime.c b/src/IO/mime.c
index 3606d23c..19311b06 100644
--- a/src/IO/mime.c
+++ b/src/IO/mime.c
@@ -116,16 +116,14 @@ void a_Mime_init()
/*
- * Call the handler for the MIME type to set Call and Data as appropriate
+ * Get the handler for the MIME type.
*
* Return Value:
- * On success: a new Dw (and Call and Data properly set).
- * On failure: NULL (and Call and Data untouched).
+ * On success: viewer
+ * On failure: NULL
*/
-void *a_Mime_set_viewer(const char *content_type, void *Ptr,
- CA_Callback_t *Call, void **Data)
+Viewer_t a_Mime_get_viewer(const char *content_type)
{
-
Viewer_t viewer;
uint_t MinSize, MajSize, i;
const char *str = content_type;
@@ -137,16 +135,9 @@ void *a_Mime_set_viewer(const char *content_type, void *Ptr,
}
MinSize = i;
- /* Try minor type */
viewer = Mime_minor_type_fetch(content_type, MinSize);
- if (viewer)
- return viewer(content_type, Ptr, Call, Data);
-
- /* Try major type */
- viewer = Mime_major_type_fetch(content_type, MajSize);
- if (viewer)
- return viewer(content_type, Ptr, Call, Data);
+ if (!viewer)
+ viewer = Mime_major_type_fetch(content_type, MajSize);
- /* Type not handled */
- return NULL;
+ return viewer;
}
diff --git a/src/IO/mime.h b/src/IO/mime.h
index 0f20cf6d..1f3b1ce5 100644
--- a/src/IO/mime.h
+++ b/src/IO/mime.h
@@ -41,8 +41,7 @@ void *a_Dicache_jpeg_image(const char *Type, void *Ptr, CA_Callback_t *Call,
* Functions defined inside Mime module
*/
void a_Mime_init(void);
-void *a_Mime_set_viewer(const char *content_type, void *Ptr,
- CA_Callback_t *Call, void **Data);
+Viewer_t a_Mime_get_viewer(const char *content_type);
#ifdef __cplusplus
}
diff --git a/src/web.cc b/src/web.cc
index 48c368be..fcc65af8 100644
--- a/src/web.cc
+++ b/src/web.cc
@@ -55,9 +55,12 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
dReturn_val_if_fail(Web->bw != NULL, -1);
- // get the Layout object from the bw structure.
Layout *layout = (Layout*)Web->bw->render_layout;
+ Viewer_t viewer = a_Mime_get_viewer(Type);
+ if (viewer == NULL)
+ return -1;
+
if (Web->flags & WEB_RootUrl) {
/* We have RootUrl! */
@@ -69,7 +72,7 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
StyleEngine styleEngine (layout);
styleEngine.startElement ("body");
- dw = (Widget*) a_Mime_set_viewer(Type, Web, Call, Data);
+ dw = (Widget*) viewer(Type, Web, Call, Data);
if (dw == NULL)
return -1;
@@ -96,7 +99,7 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
} else {
/* A non-RootUrl. At this moment we only handle image-children */
if (!dStrnAsciiCasecmp(Type, "image/", 6)) {
- dw = (Widget*) a_Mime_set_viewer(Type, Web, Call, Data);
+ dw = (Widget*) viewer(Type, Web, Call, Data);
} else {
MSG_HTTP("'%s' cannot be displayed as image; has media type '%s'\n",
URL_STR(Web->url), Type);