diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2007-03-28 22:56:54 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2007-03-28 22:56:54 +0000 |
commit | ccfc0e751610780311624b916bb39dcf76e940b1 (patch) | |
tree | b13f8bd3e49166713a5949e25211a8063dbe10fa | |
parent | 932765df961ce1a46a87bececfca78d2e157d1fc (diff) | |
download | netsurf-ccfc0e751610780311624b916bb39dcf76e940b1.tar.gz netsurf-ccfc0e751610780311624b916bb39dcf76e940b1.tar.bz2 |
Fix abort on attempted destruction of CONTENT_DIRECTORY (1690222)
svn path=/trunk/netsurf/; revision=3228
-rw-r--r-- | content/content.c | 4 | ||||
-rw-r--r-- | render/directory.c | 57 | ||||
-rw-r--r-- | render/directory.h | 1 |
3 files changed, 37 insertions, 25 deletions
diff --git a/content/content.c b/content/content.c index d4a8f3227..dd2f3b103 100644 --- a/content/content.c +++ b/content/content.c @@ -291,9 +291,7 @@ static const struct handler_entry handler_map[] = { true}, #endif {directory_create, 0, directory_convert, - html_reformat, html_destroy, html_stop, html_redraw, 0, - html_open, html_close, - true}, + 0, directory_destroy, 0, 0, 0, 0, 0, true}, #ifdef WITH_THEME_INSTALL {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false}, #endif diff --git a/render/directory.c b/render/directory.c index c64d05a77..e4b5b800d 100644 --- a/render/directory.c +++ b/render/directory.c @@ -34,8 +34,8 @@ bool directory_create(struct content *c, const char *params[]) { /* html_create() must have broadcast MSG_ERROR already, so we * don't need to. */ return false; - htmlParseChunk(c->data.html.parser, header, sizeof(header) - 1, 0); - return true; + htmlParseChunk(c->data.html.parser, header, sizeof(header) - 1, 0); + return true; } bool directory_convert(struct content *c, int width, int height) { @@ -59,22 +59,22 @@ bool directory_convert(struct content *c, int width, int height) { if (!nice_path) { msg_data.error = messages_get("MiscErr"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; + return false; } for (cnv = nice_path, tmp = path; *tmp != '\0'; *tmp++) { - if (*tmp == '<') { - *cnv++ = '&'; - *cnv++ = 'l'; - *cnv++ = 't'; - *cnv++ = ';'; - } else if (*tmp == '>') { - *cnv++ = '&'; - *cnv++ = 'g'; - *cnv++ = 't'; - *cnv++ = ';'; - } else { - *cnv++ = *tmp; - } + if (*tmp == '<') { + *cnv++ = '&'; + *cnv++ = 'l'; + *cnv++ = 't'; + *cnv++ = ';'; + } else if (*tmp == '>') { + *cnv++ = '&'; + *cnv++ = 'g'; + *cnv++ = 't'; + *cnv++ = ';'; + } else { + *cnv++ = *tmp; + } } *cnv++ = '\0'; snprintf(buffer, sizeof(buffer), "Index of %s</title>\n</head>\n" @@ -85,20 +85,20 @@ bool directory_convert(struct content *c, int width, int height) { res = url_parent(c->url, &up); if (res == URL_FUNC_OK) { - res = url_compare(c->url, up, &compare); - if (!compare) { + res = url_compare(c->url, up, &compare); + if (!compare) { snprintf(buffer, sizeof(buffer), "<a href=\"..\">[..]</a>\n"); htmlParseChunk(c->data.html.parser, buffer, strlen(buffer), 0); - } - free(up); - } + } + free(up); + } if ((parent = opendir(path)) == NULL) { msg_data.error = messages_get("EmptyErr"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; + return false; } while ((entry = readdir(parent)) != NULL) { if (!strcmp(entry->d_name, ".") || @@ -115,3 +115,16 @@ bool directory_convert(struct content *c, int width, int height) { c->type = CONTENT_HTML; return html_convert(c, width, height); } + +void directory_destroy(struct content *c) +{ + /* This will only get called if the content is destroyed before + * content_convert() is called. Simply force the type to HTML and + * delegate the cleanup to html_destroy() */ + + c->type = CONTENT_HTML; + + html_destroy(c); + + return; +} diff --git a/render/directory.h b/render/directory.h index ce1b212c3..67fb5c1c0 100644 --- a/render/directory.h +++ b/render/directory.h @@ -20,5 +20,6 @@ bool directory_create(struct content *c, const char *params[]); bool directory_convert(struct content *c, int width, int height); +void directory_destroy(struct content *c); #endif |