[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>
This commit is contained in:
Fumitoshi UKAI
2003-01-07 15:53:42 +00:00
parent b5462e1936
commit aee81bf527
3 changed files with 45 additions and 46 deletions

View File

@@ -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> 2003-01-07 Fumitoshi UKAI <ukai@debian.or.jp>
* fix build warnings * fix build warnings
@@ -6184,4 +6192,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1 * release-0-2-1
* import w3m-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 $

16
news.c
View File

@@ -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 "fm.h"
#include "myctype.h" #include "myctype.h"
#include <stdio.h> #include <stdio.h>
@@ -272,12 +272,7 @@ openNewsStream(ParsedURL *pu)
} }
if (pu->scheme == SCM_NNTP || pu->scheme == SCM_NEWS) { if (pu->scheme == SCM_NNTP || pu->scheme == SCM_NEWS) {
/* News article */ /* News article */
group = allocStr(pu->file, -1); group = file_unquote(allocStr(pu->file, -1));
if (pu->scheme == SCM_NNTP && *group == '/') {
/* first char of pu->file is '/' */
group++;
}
group = file_unquote(group);
p = strchr(group, '/'); p = strchr(group, '/');
if (p == NULL) { /* <message-id> */ if (p == NULL) { /* <message-id> */
if (!strchr(group, '@')) if (!strchr(group, '@'))
@@ -321,11 +316,8 @@ readNewsgroup(ParsedURL *pu)
if (current_news.host == NULL || !pu->file || *pu->file == '\0') if (current_news.host == NULL || !pu->file || *pu->file == '\0')
return NULL; return NULL;
group = allocStr(pu->file, -1); group = allocStr(pu->file, -1);
if (pu->scheme == SCM_NNTP_GROUP) { if (pu->scheme == SCM_NNTP_GROUP)
if (*group == '/') scheme = "/";
group++;
scheme = "nntp:/";
}
else else
scheme = "news:"; scheme = "news:";
if ((list = strchr(group, '/'))) { if ((list = strchr(group, '/'))) {

65
url.c
View File

@@ -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 "fm.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
@@ -682,12 +682,7 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)
/* RFC1808: Relative Uniform Resource Locators /* RFC1808: Relative Uniform Resource Locators
* 4. Resolving Relative URLs * 4. Resolving Relative URLs
*/ */
if (*url == '\0' && current) { if (*url == '\0' || *url == '#') {
copyParsedURL(p_url, current);
return;
}
if (*url == '#') { /* label only */
if (current) if (current)
copyParsedURL(p_url, current); copyParsedURL(p_url, current);
goto do_label; goto do_label;
@@ -713,12 +708,9 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)
* denotes a filename (therefore the scheme is SCM_LOCAL). * denotes a filename (therefore the scheme is SCM_LOCAL).
*/ */
if (current) { if (current) {
copyParsedURL(p_url, current); p_url->scheme = current->scheme;
if (p_url->scheme == SCM_LOCAL_CGI) if (p_url->scheme == SCM_LOCAL_CGI)
p_url->scheme = SCM_LOCAL; p_url->scheme = SCM_LOCAL;
/* label part and query part don't inherit */
p_url->label = NULL;
p_url->query = NULL;
} }
else else
p_url->scheme = SCM_LOCAL; p_url->scheme = SCM_LOCAL;
@@ -828,7 +820,8 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)
analyze_file: analyze_file:
#ifndef SUPPORT_NETBIOS_SHARE #ifndef SUPPORT_NETBIOS_SHARE
if (p_url->scheme == SCM_LOCAL && p_url->user == NULL && 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 * In the environments other than CYGWIN, a URL like
* file://host/file is regarded as ftp://host/file. * 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]; p_url->port = DefaultPort[SCM_FTP];
} }
#endif #endif
if ((*p == '\0' || *p == '#' || *p == '?') && p_url->host == NULL) {
p_url->file = "";
goto do_query;
}
#ifdef SUPPORT_DOS_DRIVE_PREFIX #ifdef SUPPORT_DOS_DRIVE_PREFIX
if (p_url->scheme == SCM_LOCAL) { if (p_url->scheme == SCM_LOCAL) {
q = p; q = p;
@@ -870,10 +867,9 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)
#endif /* USE_GOPHER */ #endif /* USE_GOPHER */
if (*p == '/') if (*p == '/')
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->file = DefaultFile(p_url->scheme);
p_url->label = NULL; goto do_query;
return;
} }
#ifdef USE_GOPHER #ifdef USE_GOPHER
if (p_url->scheme == SCM_GOPHER && *p == 'R') { 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); p_url->file = copyPath(q, p - q, COPYPATH_SPC_IGNORE);
} }
do_query:
if (*p == '?') { if (*p == '?') {
q = ++p; q = ++p;
while (*p && *p != '#') while (*p && *p != '#')
@@ -973,42 +970,43 @@ parseURL2(char *url, ParsedURL *pu, ParsedURL *current)
if (pu->scheme == SCM_MAILTO) if (pu->scheme == SCM_MAILTO)
return; return;
#endif #endif
if (pu->scheme == SCM_NEWS) { if (pu->scheme == SCM_NEWS || pu->scheme == SCM_NEWS_GROUP) {
if (pu->file && !strchr(pu->file, '@') && if (pu->file && !strchr(pu->file, '@') &&
(!(p = strchr(pu->file, '/')) || strchr(p + 1, '-') || (!(p = strchr(pu->file, '/')) || strchr(p + 1, '-') ||
*(p + 1) == '\0')) *(p + 1) == '\0'))
pu->scheme = SCM_NEWS_GROUP; pu->scheme = SCM_NEWS_GROUP;
else
pu->scheme = SCM_NEWS;
return; 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, '@') && if (pu->file && !strchr(pu->file, '@') &&
(!(p = strchr(pu->file + 1, '/')) || strchr(p + 1, '-') || (!(p = strchr(pu->file, '/')) || strchr(p + 1, '-') ||
*(p + 1) == '\0')) *(p + 1) == '\0'))
pu->scheme = SCM_NNTP_GROUP; pu->scheme = SCM_NNTP_GROUP;
else
pu->scheme = SCM_NNTP;
if (current && (current->scheme == SCM_NNTP || if (current && (current->scheme == SCM_NNTP ||
current->scheme == SCM_NNTP_GROUP)) { current->scheme == SCM_NNTP_GROUP)) {
if (pu->host == NULL) if (pu->host == NULL) {
pu->host = current->host; pu->host = current->host;
if (pu->port == 0)
pu->port = current->port; pu->port = current->port;
}
} }
return; return;
} }
if (pu->scheme == SCM_LOCAL) if (pu->scheme == SCM_LOCAL)
pu->file = expandName(pu->file); 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 */ /* Copy omitted element from the current URL */
if (pu->user == NULL) { pu->user = current->user;
pu->user = current->user; pu->pass = current->pass;
} pu->host = current->host;
if (pu->pass == NULL) { pu->port = current->port;
pu->pass = current->pass; if (pu->file && *pu->file) {
}
if (pu->host == NULL) {
pu->host = current->host;
}
if (pu->file) {
if ( if (
#ifdef USE_GOPHER #ifdef USE_GOPHER
pu->scheme != SCM_GOPHER && pu->scheme != SCM_GOPHER &&
@@ -1040,9 +1038,10 @@ parseURL2(char *url, ParsedURL *pu, ParsedURL *current)
} }
#endif /* USE_GOPHER */ #endif /* USE_GOPHER */
} }
else if (pu->label) { else { /* scheme:[?query][#label] */
/* pu has only label */
pu->file = current->file; pu->file = current->file;
if (!pu->query)
pu->query = current->query;
} }
/* comment: query part need not to be completed /* comment: query part need not to be completed
* from the current URL. */ * from the current URL. */