From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from re-prd-fep-048.btinternet.com (mailomta25-re.btinternet.com [213.120.69.118]) by sourceware.org (Postfix) with ESMTPS id 319DE386F432 for ; Tue, 21 Jul 2020 14:16:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 319DE386F432 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=jon.turney@dronecode.org.uk Received: from re-prd-rgout-004.btmx-prd.synchronoss.net ([10.2.54.7]) by re-prd-fep-048.btinternet.com with ESMTP id <20200721141606.PULH4701.re-prd-fep-048.btinternet.com@re-prd-rgout-004.btmx-prd.synchronoss.net>; Tue, 21 Jul 2020 15:16:06 +0100 Authentication-Results: btinternet.com; auth=pass (LOGIN) smtp.auth=jonturney@btinternet.com X-Originating-IP: [31.51.206.146] X-OWM-Source-IP: 31.51.206.146 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=15/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgeduiedrgeeigdejudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucgfrhhlucfvnfffucdludehmdenucfjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomheplfhonhcuvfhurhhnvgihuceojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheqnecuggftrfgrthhtvghrnhepgfeiieeggfdutdeludeghefhtddujedvledthfdthffhtdefvdejfefhfeeivdefnecuffhomhgrihhnpehsihhtvgdrtggtnecukfhppeefuddrhedurddvtdeirddugeeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplhhotggrlhhhohhsthdrlhhotggrlhguohhmrghinhdpihhnvghtpeefuddrhedurddvtdeirddugeeipdhmrghilhhfrhhomhepoehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkqedprhgtphhtthhopeeotgihghifihhnqdgrphhpshestgihghifihhnrdgtohhmqedprhgtphhtthhopeeojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheq X-RazorGate-Vade-Verdict: clean 15 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (31.51.206.146) by re-prd-rgout-004.btmx-prd.synchronoss.net (5.8.340) (authenticated as jonturney@btinternet.com) id 5ED9C50607FEF0E0; Tue, 21 Jul 2020 15:16:06 +0100 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup] Migrate selected sites from http:// to https:// Date: Tue, 21 Jul 2020 15:15:53 +0100 Message-Id: <20200721141553.28175-1-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin-apps@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin package maintainer discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2020 14:16:08 -0000 If a selected site URL saved from the last run starts with "http://", and an identical URL except starting with "https://" is in the current mirror list, migrate it from "http://" to "https://". --- Notes: This is useful because it lets us consolidate http:// and https:// entries in the mirror list, without causing setup to warn about http:// sites being dropped from the mirror list. site.cc | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/site.cc b/site.cc index b9a5119..2c6421f 100644 --- a/site.cc +++ b/site.cc @@ -320,6 +320,44 @@ load_site_list (SiteList& theSites, char *theString) } } +/* Protocol migrations */ +#define HTTP "http://" +#define HTTP_LEN (strlen(HTTP)) +#define HTTPS "https://" + +static void +migrate_selected_site_list() +{ + SiteList result; + + for (SiteList::const_iterator i = site_list.begin(); + i != site_list.end(); + ++i) + { + /* If the saved selected site URL starts with "http://", and the same URL, + but starting with "https://" appears in the mirror list, migrate to + "https://" */ + if (strnicmp(i->url.c_str(), HTTP, HTTP_LEN) == 0) + { + std::string migrated_site = "https://"; + migrated_site.append(&(i->url.c_str()[HTTP_LEN])); + + site_list_type migrate(migrated_site, "", "", "", false); + SiteList::iterator j = find (all_site_list.begin(), + all_site_list.end(), migrate); + if (j != all_site_list.end()) + { + Log (LOG_PLAIN) << "Migrated " << i->url << " to " << migrated_site << endLog; + result.push_back(migrate); + continue; + } + } + result.push_back(*i); + } + + site_list = result; +} + static int get_site_list (HINSTANCE h, HWND owner) { @@ -370,10 +408,12 @@ get_site_list (HINSTANCE h, HWND owner) load_site_list (all_site_list, theMirrorString); load_site_list (cached_site_list, theCachedString); - + delete[] theMirrorString; delete[] theCachedString; + migrate_selected_site_list(); + return 0; } -- 2.27.0