From 4b0c2cecc3a8f364c9377c441b3eeac791f5dd29 Mon Sep 17 00:00:00 2001 From: Dai Sato Date: Mon, 29 May 2006 12:54:26 +0000 Subject: [w3m-dev-en 01067] decode content-encoding in all situations. --- ChangeLog | 7 ++++++- file.c | 19 +++++++++++++++++-- html.h | 3 ++- url.c | 5 +++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a28924..2f55d71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-05-29 Dai Sato + + * [w3m-dev-en 01067] Some more patches + * file.c, html.h, url.c: decode content-encoding in all situations. + 2006-05-29 Dai Sato * [w3m-dev-en 01067] Some more patches @@ -8723,4 +8728,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.963 2006/05/29 12:42:22 inu Exp $ +$Id: ChangeLog,v 1.964 2006/05/29 12:54:26 inu Exp $ diff --git a/file.c b/file.c index 21cdcb0..a7e88ad 100644 --- a/file.c +++ b/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.242 2006/04/08 11:33:16 inu Exp $ */ +/* $Id: file.c,v 1.243 2006/05/29 12:54:26 inu Exp $ */ #include "fm.h" #include #include "myctype.h" @@ -748,6 +748,7 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) if (uf->compression != CMP_NOCOMPRESS) break; } + uf->content_encoding = uf->compression; } #ifdef USE_COOKIE else if (use_cookie && accept_cookie && @@ -2125,7 +2126,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, return NO_BUFFER; } - if (f.compression != CMP_NOCOMPRESS) { + if (f.content_encoding != CMP_NOCOMPRESS) { + uncompress_stream(&f, &pu.real_file); + } + else if (f.compression != CMP_NOCOMPRESS) { if (!(w3m_dump & DUMP_SOURCE) && (w3m_dump & ~DUMP_FRAME || is_text_type(t) || searchExtViewer(t))) { @@ -7814,6 +7818,7 @@ doFileSave(URLFile uf, char *defstr) char *p, *q; pid_t pid; char *lock; + char *tmpf = NULL; #if !(defined(HAVE_SYMLINK) && defined(HAVE_LSTAT)) FILE *f; #endif @@ -7854,6 +7859,11 @@ doFileSave(URLFile uf, char *defstr) flush_tty(); pid = fork(); if (!pid) { + if (uf.content_encoding != CMP_NOCOMPRESS) { + uncompress_stream(&uf, &tmpf); + if (tmpf) + unlink(tmpf); + } setup_child(FALSE, 0, UFfileno(&uf)); if (!save2tmp(uf, p) && PreserveTimestamp && uf.modtime != -1) setModtime(p, uf.modtime); @@ -7886,6 +7896,11 @@ doFileSave(URLFile uf, char *defstr) printf("Can't save. Load file and %s are identical.", p); return -1; } + if (uf.content_encoding != CMP_NOCOMPRESS) { + uncompress_stream(&uf, &tmpf); + if (tmpf) + unlink(tmpf); + } if (save2tmp(uf, p) < 0) { /* FIXME: gettextize? */ printf("Can't save to %s\n", p); diff --git a/html.h b/html.h index 28d1599..4c8173f 100644 --- a/html.h +++ b/html.h @@ -1,4 +1,4 @@ -/* $Id: html.h,v 1.25 2003/10/20 16:41:56 ukai Exp $ */ +/* $Id: html.h,v 1.26 2006/05/29 12:54:26 inu Exp $ */ #ifndef _HTML_H #define _HTML_H #ifdef USE_SSL @@ -69,6 +69,7 @@ typedef struct { InputStream stream; char *ext; int compression; + int content_encoding; char *guess_type; #ifdef USE_SSL char *ssl_certificate; diff --git a/url.c b/url.c index 2eb6e45..86c2d47 100644 --- a/url.c +++ b/url.c @@ -1,4 +1,4 @@ -/* $Id: url.c,v 1.92 2006/04/07 13:21:12 inu Exp $ */ +/* $Id: url.c,v 1.93 2006/05/29 12:54:26 inu Exp $ */ #include "fm.h" #include #include @@ -1453,7 +1453,8 @@ init_stream(URLFile *uf, int scheme, InputStream stream) uf->scheme = scheme; uf->encoding = ENC_7BIT; uf->is_cgi = FALSE; - uf->compression = 0; + uf->compression = CMP_NOCOMPRESS; + uf->content_encoding = CMP_NOCOMPRESS; uf->guess_type = NULL; uf->ext = NULL; uf->modtime = -1; -- cgit v1.2.3