diff options
| author | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-01-07 15:53:42 +0000 | 
|---|---|---|
| committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-01-07 15:53:42 +0000 | 
| commit | aee81bf527e78b8292135f3084fa741212cf0b76 (patch) | |
| tree | 3eb4a573e1fd61f0904dc117df3b2804efc057b4 | |
| parent | fix build warnings (diff) | |
| download | w3m-aee81bf527e78b8292135f3084fa741212cf0b76.tar.gz w3m-aee81bf527e78b8292135f3084fa741212cf0b76.zip | |
[w3m-dev 03611] relative URL
* news.c (openNewsStream): don't skip '/' for nntp:
	(readNewsgroup): cleanup
* url.c (parseURL): don't copy user & password
	(parseURL2): fix for group, don't copy user & password
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
| -rw-r--r-- | ChangeLog | 10 | ||||
| -rw-r--r-- | news.c | 16 | ||||
| -rw-r--r-- | url.c | 65 | 
3 files changed, 45 insertions, 46 deletions
| @@ -1,3 +1,11 @@ +2003-01-08  Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + +	* [w3m-dev 03611] relative URL +	* news.c (openNewsStream): don't skip '/' for nntp: +		(readNewsgroup): cleanup +	* url.c (parseURL): don't copy user & password +		(parseURL2): fix for group, don't copy user & password +  2003-01-07  Fumitoshi UKAI  <ukai@debian.or.jp>  	* fix build warnings @@ -6184,4 +6192,4 @@ a	* [w3m-dev 03276] compile error on EWS4800  	* release-0-2-1  	* import w3m-0.2.1 -$Id: ChangeLog,v 1.657 2003/01/06 15:49:28 ukai Exp $ +$Id: ChangeLog,v 1.658 2003/01/07 15:53:42 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: news.c,v 1.8 2003/01/06 15:49:29 ukai Exp $ */ +/* $Id: news.c,v 1.9 2003/01/07 15:53:43 ukai Exp $ */  #include "fm.h"  #include "myctype.h"  #include <stdio.h> @@ -272,12 +272,7 @@ openNewsStream(ParsedURL *pu)      }      if (pu->scheme == SCM_NNTP || pu->scheme == SCM_NEWS) {  	/* News article */ -	group = allocStr(pu->file, -1); -	if (pu->scheme == SCM_NNTP && *group == '/') { -	    /* first char of pu->file is '/' */ -	    group++; -	} -	group = file_unquote(group); +	group = file_unquote(allocStr(pu->file, -1));  	p = strchr(group, '/');  	if (p == NULL) {	/* <message-id> */  	    if (!strchr(group, '@')) @@ -321,11 +316,8 @@ readNewsgroup(ParsedURL *pu)      if (current_news.host == NULL || !pu->file || *pu->file == '\0')  	return NULL;      group = allocStr(pu->file, -1); -    if (pu->scheme == SCM_NNTP_GROUP) { -	if (*group == '/') -	    group++; -	scheme = "nntp:/"; -    } +    if (pu->scheme == SCM_NNTP_GROUP) +	scheme = "/";      else  	scheme = "news:";      if ((list = strchr(group, '/'))) { @@ -1,4 +1,4 @@ -/* $Id: url.c,v 1.64 2003/01/06 15:49:29 ukai Exp $ */ +/* $Id: url.c,v 1.65 2003/01/07 15:53:43 ukai Exp $ */  #include "fm.h"  #include <sys/types.h>  #include <sys/socket.h> @@ -682,12 +682,7 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)      /* RFC1808: Relative Uniform Resource Locators       * 4.  Resolving Relative URLs       */ -    if (*url == '\0' && current) { -	copyParsedURL(p_url, current); -	return; -    } - -    if (*url == '#') {		/* label only */ +    if (*url == '\0' || *url == '#') {  	if (current)  	    copyParsedURL(p_url, current);  	goto do_label; @@ -713,12 +708,9 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)  	 * denotes a filename (therefore the scheme is SCM_LOCAL).  	 */  	if (current) { -	    copyParsedURL(p_url, current); +	    p_url->scheme = current->scheme;  	    if (p_url->scheme == SCM_LOCAL_CGI)  		p_url->scheme = SCM_LOCAL; -	    /* label part and query part don't inherit */ -	    p_url->label = NULL; -	    p_url->query = NULL;  	}  	else  	    p_url->scheme = SCM_LOCAL; @@ -828,7 +820,8 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)    analyze_file:  #ifndef SUPPORT_NETBIOS_SHARE      if (p_url->scheme == SCM_LOCAL && p_url->user == NULL && -	p_url->host != NULL && strcmp(p_url->host, "localhost")) { +	p_url->host != NULL && *p_url->host != '\0' && +	strcmp(p_url->host, "localhost")) {  	/*  	 * In the environments other than CYGWIN, a URL like   	 * file://host/file is regarded as ftp://host/file. @@ -843,6 +836,10 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)  	    p_url->port = DefaultPort[SCM_FTP];      }  #endif +    if ((*p == '\0' || *p == '#' || *p == '?') && p_url->host == NULL) { +	p_url->file = ""; +	goto do_query; +    }  #ifdef SUPPORT_DOS_DRIVE_PREFIX      if (p_url->scheme == SCM_LOCAL) {  	q = p; @@ -870,10 +867,9 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)  #endif				/* USE_GOPHER */      if (*p == '/')  	p++; -    if (*p == '\0') {		/* scheme://host[:port]/ */ +    if (*p == '\0' || *p == '#' || *p == '?') {	/* scheme://host[:port]/ */  	p_url->file = DefaultFile(p_url->scheme); -	p_url->label = NULL; -	return; +	goto do_query;      }  #ifdef USE_GOPHER      if (p_url->scheme == SCM_GOPHER && *p == 'R') { @@ -925,6 +921,7 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)  	    p_url->file = copyPath(q, p - q, COPYPATH_SPC_IGNORE);      } +  do_query:      if (*p == '?') {  	q = ++p;  	while (*p && *p != '#') @@ -973,42 +970,43 @@ parseURL2(char *url, ParsedURL *pu, ParsedURL *current)      if (pu->scheme == SCM_MAILTO)  	return;  #endif -    if (pu->scheme == SCM_NEWS) { +    if (pu->scheme == SCM_NEWS || pu->scheme == SCM_NEWS_GROUP) {  	if (pu->file && !strchr(pu->file, '@') &&  	    (!(p = strchr(pu->file, '/')) || strchr(p + 1, '-') ||  	     *(p + 1) == '\0'))  	    pu->scheme = SCM_NEWS_GROUP; +	else +	    pu->scheme = SCM_NEWS;  	return;      } -    if (pu->scheme == SCM_NNTP) { +    if (pu->scheme == SCM_NNTP || pu->scheme == SCM_NNTP_GROUP) { +	if (pu->file && *pu->file == '/') +	    pu->file = allocStr(pu->file + 1, -1);  	if (pu->file && !strchr(pu->file, '@') && -	    (!(p = strchr(pu->file + 1, '/')) || strchr(p + 1, '-') || +	    (!(p = strchr(pu->file, '/')) || strchr(p + 1, '-') ||  	     *(p + 1) == '\0'))  	    pu->scheme = SCM_NNTP_GROUP; +	else +	    pu->scheme = SCM_NNTP;  	if (current && (current->scheme == SCM_NNTP ||  			current->scheme == SCM_NNTP_GROUP)) { -	    if (pu->host == NULL) +	    if (pu->host == NULL) {  		pu->host = current->host; -	    if (pu->port == 0)  		pu->port = current->port; +	    }  	}  	return;      }      if (pu->scheme == SCM_LOCAL)  	pu->file = expandName(pu->file); -    if (current && pu->scheme == current->scheme) { +    if (current && pu->scheme == current->scheme && pu->host == NULL) {  	/* Copy omitted element from the current URL */ -	if (pu->user == NULL) { -	    pu->user = current->user; -	} -	if (pu->pass == NULL) { -	    pu->pass = current->pass; -	} -	if (pu->host == NULL) { -	    pu->host = current->host; -	} -	if (pu->file) { +	pu->user = current->user; +	pu->pass = current->pass; +	pu->host = current->host; +	pu->port = current->port; +	if (pu->file && *pu->file) {  	    if (  #ifdef USE_GOPHER  		   pu->scheme != SCM_GOPHER && @@ -1040,9 +1038,10 @@ parseURL2(char *url, ParsedURL *pu, ParsedURL *current)  	    }  #endif				/* USE_GOPHER */  	} -	else if (pu->label) { -	    /* pu has only label */ +	else {	/* scheme:[?query][#label] */  	    pu->file = current->file; +	    if (!pu->query) +		pu->query = current->query;  	}  	/* comment: query part need not to be completed  	 * from the current URL. */ | 
