w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit cb249cc96466be26a69cec3eaf3456fbbd7ecf63
parent 8de1c829b3afd11eae9a89c443d914ff26deb033
Author: ukai <ukai>
Date:   Tue,  7 Jan 2003 15:53:42 +0000

[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>

Diffstat:
MChangeLog | 8++++++++
Mnews.c | 14+++-----------
Murl.c | 63+++++++++++++++++++++++++++++++--------------------------------
3 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -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 diff --git a/news.c b/news.c @@ -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, '/'))) { diff --git a/url.c b/url.c @@ -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. */