diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2021-04-10 13:29:18 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2021-04-10 13:29:18 +0000 |
commit | 22d33dc8c925293dccfdfc0a0d6517cd5d3f0b5c (patch) | |
tree | f8fffbefb80abdade831b9314501f44181551357 /url.c | |
parent | Don't include username in Referer (diff) | |
download | w3m-22d33dc8c925293dccfdfc0a0d6517cd5d3f0b5c.tar.gz w3m-22d33dc8c925293dccfdfc0a0d6517cd5d3f0b5c.zip |
New option cross_origin_referer to use origin only Referer
Diffstat (limited to 'url.c')
-rw-r--r-- | url.c | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -1374,6 +1374,21 @@ parsedURL2Str(ParsedURL *pu) return _parsedURL2Str(pu, FALSE, TRUE, TRUE); } +static Str +parsedURL2RefererOriginStr(ParsedURL *pu) +{ + Str s; + char *f = pu->file, *q = pu->query; + + pu->file = NULL; + pu->query = NULL; + s = _parsedURL2Str(pu, FALSE, FALSE, FALSE); + pu->file = f; + pu->query = q; + + return s; +} + Str parsedURL2RefererStr(ParsedURL *pu) { @@ -1455,6 +1470,13 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer) no_referer_ptr = query_SCONF_NO_REFERER_TO(target); no_referer = no_referer || (no_referer_ptr && *no_referer_ptr); if (!no_referer) { + int cross_origin = FALSE; + if (CrossOriginReferer && current && current->host && + (!target || !target->host || + strcasecmp(current->host, target->host) != 0 || + current->port != target->port || + current->scheme != target->scheme)) + cross_origin = TRUE; #ifdef USE_SSL if (current && current->scheme == SCM_HTTPS && target->scheme != SCM_HTTPS) { /* Don't send Referer: if https:// -> http:// */ @@ -1466,12 +1488,18 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer) (current->scheme != SCM_FTP || (current->user == NULL && current->pass == NULL))) { Strcat_charp(s, "Referer: "); - Strcat(s, parsedURL2RefererStr(current)); + if (cross_origin) + Strcat(s, parsedURL2RefererOriginStr(current)); + else + Strcat(s, parsedURL2RefererStr(current)); Strcat_charp(s, "\r\n"); } else if (referer != NULL && referer != NO_REFERER) { Strcat_charp(s, "Referer: "); - Strcat_charp(s, referer); + if (cross_origin) + Strcat(s, parsedURL2RefererOriginStr(current)); + else + Strcat_charp(s, referer); Strcat_charp(s, "\r\n"); } } |