diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2021-04-10 03:19:58 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2021-04-10 03:19:58 +0000 |
commit | 4e0375c76fcc301d523242bffc6ac5c015b7e4e0 (patch) | |
tree | 5e10352b8a9f12dcef1c9d3de4d2c5b24e0e05f4 /url.c | |
parent | Don't set Referer when data URI scheme (diff) | |
download | w3m-4e0375c76fcc301d523242bffc6ac5c015b7e4e0.tar.gz w3m-4e0375c76fcc301d523242bffc6ac5c015b7e4e0.zip |
Don't include username in Referer
Diffstat (limited to '')
-rw-r--r-- | url.c | 37 |
1 files changed, 16 insertions, 21 deletions
@@ -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; } |