[prev in list] [next in list] [prev in thread] [next in thread]
List: elinks-dev
Subject: [elinks-dev] [PATCH] Content-Type handling in elinks 0.9.2
From: Jakub Bogusz <qboosh () pld-linux ! org>
Date: 2004-11-06 0:35:49
Message-ID: 20041106003549.GA10981 () satan ! blackhosts
[Download RAW message or body]
Hello,
This patch contains two changes against elinks 0.9.2:
1) fixes crash[1] on empty Content-Type header from server
(due to hash lookup with empty ctype as key) by treating empty
Content-Type header as if it was not present at all
2) adds Content-Type header to uploaded files
(ported from links-1.00pre8)
[1] backtrace if you are interested:
#0 0x402207a1 in kill () from /lib/libc.so.6
#1 0x40220525 in raise () from /lib/libc.so.6
#2 0x40221b10 in abort () from /lib/libc.so.6
#3 0x080a06d9 in sig_segv (t=0x8244d11) at signals.c:119
#4 0x080a0a6c in got_signal (sig=11) at signals.c:224
#5 <signal handler called>
#6 0x402207a1 in kill () from /lib/libc.so.6
#7 0x40220525 in raise () from /lib/libc.so.6
#8 0x080e5699 in force_dump () at error.c:149
#9 0x080e559d in elinks_internal (fmt=0x810f940 "assertion k && length > 0 failed!")
at error.c:110
#10 0x080e73e4 in strhash (k=0x82461c9 "", length=0, initval=3735928559) at hash.c:146
#11 0x080e70db in get_hash_item (hash=0x824fb19, key=0x82461c9 "", keylen=0) at hash.c:98
#12 0x080d4eb7 in get_mailcap_entry (type=0x82461c9 "") at mailcap.c:638
#13 0x080d503f in get_mime_handler_mailcap (type=0x82461c9 "", options=0) at mailcap.c:685
#14 0x080d3ed8 in get_mime_handler_backends (ctype=0x82461c9 "", have_x=0) at common.c:67
#15 0x080d3cbc in get_mime_type_handler (content_type=0x82461c9 "", xwin=0) at mime.c:174
#16 0x08093cab in ses_chktype (ses=0x824db91, loading=0x824dbcd, ce=0x824f629, frame=0)
at download.c:1079
#17 0x08099b5f in do_move (ses=0x824db91, stat=0xbfffef00) at task.c:392
#18 0x08099cb6 in end_load (stat=0x824dbcd, ses=0x824db91) at task.c:430
#19 0x0808f39f in send_connection_info (conn=0x824ddb9) at connection.c:403
#20 0x0808f442 in done_connection (conn=0x824ddb9) at connection.c:413
#21 0x0808f8cf in add_keepalive_connection (conn=0x824ddb9, timeout=60000) at connection.c:510
#22 0x080b62b8 in http_end_request (conn=0x824ddb9, state=S_OK, notrunc=0) at http.c:252
#23 0x080b7f88 in read_http_data (conn=0x824ddb9, rb=0x824fb19) at http.c:1008
#24 0x080b9240 in http_got_header (conn=0x824ddb9, rb=0x824fb19) at http.c:1413
#25 0x0809b593 in read_select (conn=0x824ddb9) at connect.c:525
#26 0x0809e440 in select_loop (init=0x80556b8 <init>) at select.c:367
#27 0x08055ddc in main (argc=2, argv=0xbffff144) at main.c:277
--
Jakub Bogusz http://cyber.cs.net.pl/~qboosh/
PLD Team http://www.pld-linux.org/
["elinks-content-type.patch" (text/plain)]
src/mime/mime.c change fixes crash on empty Content-Type (due to hash lookup
with empty ctype used as key)
src/viewer/text/form.c change adds Content-Type header to file uploads
(port from links-1.00pre8)
--- elinks-0.9.2/src/mime/mime.c.orig 2004-07-29 12:10:10.000000000 +0200
+++ elinks-0.9.2/src/mime/mime.c 2004-11-05 23:30:59.877593784 +0100
@@ -126,6 +126,10 @@
if (head) {
ctype = parse_http_header(head, "Content-Type", NULL);
if (ctype) {
+ if (*ctype == '\0') {
+ /* treat empty Content-Type as not present (to avoid crash) */
+ mem_free(ctype);
+ } else {
unsigned char *end = strchr(ctype, ';');
int ctypelen;
@@ -139,6 +143,7 @@
return ctype;
}
+ }
}
/* We can't use the extension string we are getting below, because we
--- elinks-0.9.2/src/viewer/text/form.c.orig 2004-01-08 04:44:01.000000000 +0100
+++ elinks-0.9.2/src/viewer/text/form.c 2004-11-06 00:28:36.941040256 +0100
@@ -562,13 +562,20 @@
#define F_BUFLEN 1024
int fh, rd;
unsigned char buffer[F_BUFLEN];
+ unsigned char *ct;
add_to_string(data, "\"; filename=\"");
add_to_string(data, strip_file_name(sv->value));
/* It sends bad data if the file name contains ", but
Netscape does the same */
/* FIXME: is this a reason ? --Zas */
- add_to_string(data, "\"\r\n\r\n");
+ add_to_string(data, "\"");
+ if ((ct = get_content_type(NULL, sv->value))) {
+ add_to_string(data, "\r\nContent-Type: ");
+ add_to_string(data, ct);
+ mem_free(ct);
+ }
+ add_to_string(data, "\r\n\r\n");
if (*sv->value) {
unsigned char *filename;
_______________________________________________
ELinks-dev mailing list
ELinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic