aboutsummaryrefslogtreecommitdiffstats
path: root/url.c
diff options
context:
space:
mode:
Diffstat (limited to 'url.c')
-rw-r--r--url.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/url.c b/url.c
index f099a0e..25bfb1b 100644
--- a/url.c
+++ b/url.c
@@ -1276,7 +1276,7 @@ parseURL2(char *url, ParsedURL *pu, ParsedURL *current)
}
static Str
-_parsedURL2Str(ParsedURL *pu, int pass)
+_parsedURL2Str(ParsedURL *pu, int pass, int user, int label)
{
Str tmp;
static char *scheme_str[] = {
@@ -1293,13 +1293,13 @@ _parsedURL2Str(ParsedURL *pu, int pass)
else if (pu->scheme == SCM_UNKNOWN) {
return Strnew_charp(pu->file);
}
- if (pu->host == NULL && pu->file == NULL && pu->label != NULL) {
+ if (pu->host == NULL && pu->file == NULL && label && pu->label != NULL) {
/* local label */
return Sprintf("#%s", pu->label);
}
if (pu->scheme == SCM_LOCAL && !strcmp(pu->file, "-")) {
tmp = Strnew_charp("-");
- if (pu->label) {
+ if (label && pu->label) {
Strcat_char(tmp, '#');
Strcat_charp(tmp, pu->label);
}
@@ -1327,7 +1327,7 @@ _parsedURL2Str(ParsedURL *pu, int pass)
{
Strcat_charp(tmp, "//");
}
- if (pu->user) {
+ if (user && pu->user) {
Strcat_charp(tmp, pu->user);
if (pass && pu->pass) {
Strcat_char(tmp, ':');
@@ -1361,7 +1361,7 @@ _parsedURL2Str(ParsedURL *pu, int pass)
Strcat_char(tmp, '?');
Strcat_charp(tmp, pu->query);
}
- if (pu->label) {
+ if (label && pu->label) {
Strcat_char(tmp, '#');
Strcat_charp(tmp, pu->label);
}
@@ -1371,7 +1371,13 @@ _parsedURL2Str(ParsedURL *pu, int pass)
Str
parsedURL2Str(ParsedURL *pu)
{
- return _parsedURL2Str(pu, FALSE);
+ return _parsedURL2Str(pu, FALSE, TRUE, TRUE);
+}
+
+Str
+parsedURL2RefererStr(ParsedURL *pu)
+{
+ return _parsedURL2Str(pu, FALSE, FALSE, FALSE);
}
int
@@ -1459,20 +1465,13 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer)
current->scheme != SCM_LOCAL_CGI && current->scheme != SCM_DATA &&
(current->scheme != SCM_FTP ||
(current->user == NULL && current->pass == NULL))) {
- char *p = current->label;
Strcat_charp(s, "Referer: ");
- current->label = NULL;
- Strcat(s, parsedURL2Str(current));
- current->label = p;
+ Strcat(s, parsedURL2RefererStr(current));
Strcat_charp(s, "\r\n");
}
else if (referer != NULL && referer != NO_REFERER) {
- char *p = strchr(referer, '#');
Strcat_charp(s, "Referer: ");
- if (p)
- Strcat_charp_n(s, referer, p - referer);
- else
- Strcat_charp(s, referer);
+ Strcat_charp(s, referer);
Strcat_charp(s, "\r\n");
}
}
@@ -1513,12 +1512,8 @@ HTTPrequestURI(ParsedURL *pu, HRequest *hr)
Strcat_charp(tmp, pu->query);
}
}
- else {
- char *save_label = pu->label;
- pu->label = NULL;
- Strcat(tmp, _parsedURL2Str(pu, TRUE));
- pu->label = save_label;
- }
+ else
+ Strcat(tmp, _parsedURL2Str(pu, TRUE, TRUE, FALSE));
return tmp;
}