From 17a3df7440781c2c1e79a90579ff29ebde8f8e51 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Sat, 17 Apr 2021 17:42:01 +0900 Subject: New option localhost_only to restrict connections only to localhost Bug-Debian: https://github.com/tats/w3m/issues/117 --- fm.h | 1 + rc.c | 3 +++ url.c | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/fm.h b/fm.h index e847567..594b457 100644 --- a/fm.h +++ b/fm.h @@ -836,6 +836,7 @@ global char AutoUncompress init(FALSE); global char PreserveTimestamp init(TRUE); global char ArgvIsURL init(TRUE); global char MetaRefresh init(FALSE); +global char LocalhostOnly init(FALSE); global char fmInitialized init(FALSE); global char QuietMessage init(FALSE); diff --git a/rc.c b/rc.c index c93dcd6..469e6af 100644 --- a/rc.c +++ b/rc.c @@ -223,6 +223,7 @@ static int OptionEncode = FALSE; #endif #define CMT_FOLLOW_REDIRECTION N_("Number of redirections to follow") #define CMT_META_REFRESH N_("Enable processing of meta-refresh tag") +#define CMT_LOCALHOST_ONLY N_("Restrict connections only to localhost") #ifdef USE_MIGEMO #define CMT_USE_MIGEMO N_("Enable Migemo (Roma-ji search)") @@ -698,6 +699,8 @@ struct param_ptr params9[] = { CMT_FOLLOW_REDIRECTION, NULL}, {"meta_refresh", P_CHARINT, PI_ONOFF, (void *)&MetaRefresh, CMT_META_REFRESH, NULL}, + {"localhost_only", P_CHARINT, PI_ONOFF, (void *)&LocalhostOnly, + CMT_LOCALHOST_ONLY, NULL}, #ifdef INET6 {"dns_order", P_INT, PI_SEL_C, (void *)&DNS_order, CMT_DNS_ORDER, (void *)dnsorders}, diff --git a/url.c b/url.c index 55a794d..0c0b709 100644 --- a/url.c +++ b/url.c @@ -1696,6 +1696,10 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current, } } + if (LocalhostOnly && pu->host && + strcasecmp(pu->host, "localhost") && strcasecmp(pu->host, "127.0.0.1")) + pu->host = NULL; + uf.scheme = pu->scheme; uf.url = parsedURL2Str(pu)->ptr; pu->is_nocache = (option->flag & RG_NOCACHE); -- cgit v1.2.3