diff options
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | proto.h | 1 | ||||
-rw-r--r-- | url.c | 37 |
3 files changed, 19 insertions, 23 deletions
@@ -2948,7 +2948,7 @@ loadLink(char *url, char *target, char *referer, FormList *request) base->scheme == SCM_DATA) referer = NO_REFERER; if (referer == NULL) - referer = parsedURL2Str(&Currentbuf->currentURL)->ptr; + referer = parsedURL2RefererStr(&Currentbuf->currentURL)->ptr; buf = loadGeneralFile(url, baseURL(Currentbuf), referer, flag, request); if (buf == NULL) { char *emsg = Sprintf("Can't load %s", url)->ptr; @@ -4247,7 +4247,7 @@ goURL0(char *prompt, int relative) current->scheme == SCM_DATA) referer = NO_REFERER; else - referer = parsedURL2Str(&Currentbuf->currentURL)->ptr; + referer = parsedURL2RefererStr(&Currentbuf->currentURL)->ptr; url = url_encode(url, current, Currentbuf->document_charset); } else { @@ -544,6 +544,7 @@ extern void parseURL(char *url, ParsedURL *p_url, ParsedURL *current); extern void copyParsedURL(ParsedURL *p, const ParsedURL *q); extern void parseURL2(char *url, ParsedURL *pu, ParsedURL *current); extern Str parsedURL2Str(ParsedURL *pu); +extern Str parsedURL2RefererStr(ParsedURL *pu); extern int getURLScheme(char **url); extern void init_stream(URLFile *uf, int scheme, InputStream stream); Str HTTPrequestMethod(HRequest *hr); @@ -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; } |