diff options
-rw-r--r-- | ChangeLog | 28 | ||||
-rw-r--r-- | file.c | 9 | ||||
-rw-r--r-- | html.h | 7 | ||||
-rw-r--r-- | indep.c | 35 | ||||
-rw-r--r-- | indep.h | 6 | ||||
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | url.c | 66 |
7 files changed, 106 insertions, 51 deletions
@@ -1,3 +1,29 @@ +2003-01-09 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03616] Re: data: URL scheme + * file.c (loadGeneralFile): check SCM_DATA + (loadImageBuffer): newBuffer() + * html.h (SCM_DATA): added + * indep.c (url_unquote): deleted + (Str_url_unquote): renamed from Str_form_unquote + + is decoded is_form only + * indep.h (url_unquote): deleted + (Str_url_unquote): added + (Str_form_unquote): define by Str_url_unquote + * main.c (followA): file_unquote + (cmd_loadURL): file_unquote + * url.c (DefaultPort): add for data: + (schemetable): add "data" + (DefaultFile): SCM_FTPDIR + (parseURL): scheme copied from current + (parseURL2): SCM_DATA + check SCM_FTP, SCM_FTPDIR + (_parsedURL2Str): add data in scheme_str + handle SCM_DATA + SCM_FTPDIR + (openURL): file_unquote + handle SCM_DATA + 2003-01-08 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03611] relative URL @@ -6192,4 +6218,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.658 2003/01/07 15:53:42 ukai Exp $ +$Id: ChangeLog,v 1.659 2003/01/08 17:24:11 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.175 2003/01/06 15:36:58 ukai Exp $ */ +/* $Id: file.c,v 1.176 2003/01/08 17:24:12 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -1870,6 +1870,9 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, } #endif } + else if (pu.scheme == SCM_DATA) { + t = f.guess_type; + } else if (searchHeader) { t_buf = newBuffer(INIT_BUFFER_WIDTH); readHeader(&f, t_buf, searchHeader_through, &pu); @@ -6867,13 +6870,13 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf) cache->index = 0; image_buffer: + if (newBuf == NULL) + newBuf = newBuffer(INIT_BUFFER_WIDTH); cache->loaded |= IMG_FLAG_DONT_REMOVE; if (uf->scheme != SCM_LOCAL) newBuf->sourcefile = cache->file; tmp = Sprintf("<img src=\"%s\"><br><br>", html_quote(image->url)); - if (newBuf == NULL) - newBuf = newBuffer(INIT_BUFFER_WIDTH); tmpf = tmpfname(TMPF_SRC, ".html"); src = fopen(tmpf->ptr, "w"); newBuf->mailcap_source = tmpf->ptr; @@ -1,4 +1,4 @@ -/* $Id: html.h,v 1.18 2003/01/06 15:36:59 ukai Exp $ */ +/* $Id: html.h,v 1.19 2003/01/08 17:24:12 ukai Exp $ */ #ifndef _HTML_H #define _HTML_H #ifdef USE_SSL @@ -364,9 +364,10 @@ struct environment { #define SCM_NNTP_GROUP 8 #define SCM_NEWS 9 #define SCM_NEWS_GROUP 10 -#define SCM_MAILTO 11 +#define SCM_DATA 11 +#define SCM_MAILTO 12 #ifdef USE_SSL -#define SCM_HTTPS 12 +#define SCM_HTTPS 13 #endif /* USE_SSL */ #endif /* _HTML_H */ @@ -1,4 +1,4 @@ -/* $Id: indep.c,v 1.27 2002/12/24 17:20:47 ukai Exp $ */ +/* $Id: indep.c,v 1.28 2003/01/08 17:24:12 ukai Exp $ */ #include "fm.h" #include <stdio.h> #include <pwd.h> @@ -535,34 +535,6 @@ url_quote(char *str) } char * -url_unquote(char *str) -{ - Str tmp = NULL; - char *p, *q; - int c; - - for (p = str; *p;) { - if (*p == '%') { - q = p; - c = url_unquote_char(&q); - if (c >= 0 && c != '\0' && c != '\n' && c != '\r') { - if (tmp == NULL) - tmp = Strnew_charp_n(str, (int)(p - str)); - Strcat_char(tmp, (char)c); - p = q; - continue; - } - } - if (tmp) - Strcat_char(tmp, *p); - p++; - } - if (tmp) - return tmp->ptr; - return str; -} - -char * file_quote(char *str) { Str tmp = NULL; @@ -661,15 +633,16 @@ Str_form_quote(Str x) return x; } + Str -Str_form_unquote(Str x) +Str_url_unquote(Str x, int is_form) { Str tmp = NULL; char *p = x->ptr, *ep = x->ptr + x->length, *q; int c; for (; p < ep;) { - if (*p == '+') { + if (is_form && *p == '+') { if (tmp == NULL) tmp = Strnew_charp_n(x->ptr, (int)(p - x->ptr)); Strcat_char(tmp, ' '); @@ -1,4 +1,4 @@ -/* $Id: indep.h,v 1.10 2002/11/09 21:55:24 ukai Exp $ */ +/* $Id: indep.h,v 1.11 2003/01/08 17:24:12 ukai Exp $ */ #ifndef INDEP_H #define INDEP_H #include "gc.h" @@ -45,9 +45,9 @@ extern char *html_unquote(char *str); extern char *file_quote(char *str); extern char *file_unquote(char *str); extern char *url_quote(char *str); -extern char *url_unquote(char *str); +extern Str Str_url_unquote(Str x, int is_form); extern Str Str_form_quote(Str x); -extern Str Str_form_unquote(Str x); +#define Str_form_unquote(x) Str_url_unquote((x), TRUE) extern char *shell_quote(char *str); extern char *w3m_auxbin_dir(); @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.184 2003/01/06 15:36:59 ukai Exp $ */ +/* $Id: main.c,v 1.185 2003/01/08 17:24:13 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -2864,7 +2864,7 @@ followA(void) Strtruncate(to, pos - to->ptr); #endif fmTerm(); - system(myExtCommand(Mailer, shell_quote(url_unquote(to->ptr)), + system(myExtCommand(Mailer, shell_quote(file_unquote(to->ptr)), FALSE)->ptr); fmInit(); displayBuffer(Currentbuf, B_FORCE_REDRAW); @@ -3819,7 +3819,7 @@ cmd_loadURL(char *url, ParsedURL *current, char *referer) Strtruncate(to, pos - to->ptr); #endif fmTerm(); - system(myExtCommand(Mailer, shell_quote(url_unquote(to->ptr)), + system(myExtCommand(Mailer, shell_quote(file_unquote(to->ptr)), FALSE)->ptr); fmInit(); displayBuffer(Currentbuf, B_FORCE_REDRAW); @@ -1,4 +1,4 @@ -/* $Id: url.c,v 1.65 2003/01/07 15:53:43 ukai Exp $ */ +/* $Id: url.c,v 1.66 2003/01/08 17:24:13 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include <sys/socket.h> @@ -56,6 +56,7 @@ static int 119, /* nntp group */ 119, /* news */ 119, /* news group */ + 0, /* data - not defined */ 0, /* mailto - not defined */ #ifdef USE_SSL 443, /* https */ @@ -73,6 +74,7 @@ struct cmdtable schemetable[] = { /* {"nntp", SCM_NNTP_GROUP}, */ {"news", SCM_NEWS}, /* {"news", SCM_NEWS_GROUP}, */ + {"data", SCM_DATA}, #ifndef USE_W3MMAILER {"mailto", SCM_MAILTO}, #endif @@ -226,6 +228,7 @@ DefaultFile(int scheme) case SCM_LOCAL: case SCM_LOCAL_CGI: case SCM_FTP: + case SCM_FTPDIR: return allocStr("/", -1); } return NULL; @@ -708,9 +711,29 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current) * denotes a filename (therefore the scheme is SCM_LOCAL). */ if (current) { - p_url->scheme = current->scheme; - if (p_url->scheme == SCM_LOCAL_CGI) - p_url->scheme = SCM_LOCAL; + switch (current->scheme) { + case SCM_LOCAL: + case SCM_LOCAL_CGI: + p_url->scheme = SCM_LOCAL; + break; + case SCM_FTP: + case SCM_FTPDIR: + p_url->scheme = SCM_FTP; + break; +#ifdef USE_NNTP + case SCM_NNTP: + case SCM_NNTP_GROUP: + p_url->scheme = SCM_NNTP; + break; + case SCM_NEWS: + case SCM_NEWS_GROUP: + p_url->scheme = SCM_NEWS; + break; +#endif + default: + p_url->scheme = current->scheme; + break; + } } else p_url->scheme = SCM_LOCAL; @@ -970,6 +993,8 @@ parseURL2(char *url, ParsedURL *pu, ParsedURL *current) if (pu->scheme == SCM_MAILTO) return; #endif + if (pu->scheme == SCM_DATA) + return; if (pu->scheme == SCM_NEWS || pu->scheme == SCM_NEWS_GROUP) { if (pu->file && !strchr(pu->file, '@') && (!(p = strchr(pu->file, '/')) || strchr(p + 1, '-') || @@ -1000,7 +1025,9 @@ parseURL2(char *url, ParsedURL *pu, ParsedURL *current) if (pu->scheme == SCM_LOCAL) pu->file = expandName(pu->file); - if (current && pu->scheme == current->scheme && pu->host == NULL) { + if (current && (pu->scheme == current->scheme || + (pu->scheme == SCM_FTP && current->scheme == SCM_FTPDIR)) + && pu->host == NULL) { /* Copy omitted element from the current URL */ pu->user = current->user; pu->pass = current->pass; @@ -1120,7 +1147,7 @@ _parsedURL2Str(ParsedURL *pu, int pass) Str tmp; static char *scheme_str[] = { "http", "gopher", "ftp", "ftp", "file", "file", "exec", "nntp", "nntp", - "news", "news", "mailto", + "news", "news", "data", "mailto", #ifdef USE_SSL "https", #endif /* USE_SSL */ @@ -1156,6 +1183,10 @@ _parsedURL2Str(ParsedURL *pu, int pass) return tmp; } #endif + if (pu->scheme == SCM_DATA) { + Strcat_charp(tmp, pu->file); + return tmp; + } #ifdef USE_NNTP if (pu->scheme != SCM_NEWS && pu->scheme != SCM_NEWS_GROUP) #endif /* USE_NNTP */ @@ -1593,6 +1624,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current, } return uf; case SCM_FTP: + case SCM_FTPDIR: if (pu->file == NULL) pu->file = allocStr("/", -1); if (non_null(FTP_proxy) && @@ -1769,7 +1801,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current, return uf; if (pu->file == NULL) pu->file = "1"; - tmp = Strnew_charp(url_unquote(pu->file)); + tmp = Strnew_charp(file_unquote(pu->file)); Strcat_char(tmp, '\n'); } write(sock, tmp->ptr, tmp->length); @@ -1787,6 +1819,26 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current, uf.stream = openNewsStream(pu); return uf; #endif /* USE_NNTP */ + case SCM_DATA: + if (pu->file == NULL) + return uf; + p = Strnew_charp(pu->file)->ptr; + q = strchr(p, ','); + if (q == NULL) + return uf; + *q++ = '\0'; + tmp = Strnew_charp(q); + q = strrchr(p, ';'); + if (q != NULL && !strcmp(q, ";base64")) + { + *q = '\0'; + uf.encoding = ENC_BASE64; + } + else + tmp = Str_url_unquote(tmp, FALSE); + uf.stream = newStrStream(tmp); + uf.guess_type = (*p != '\0') ? p : "text/plain"; + return uf; case SCM_UNKNOWN: default: return uf; |