From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id C383F1F9E0 for ; Wed, 22 Apr 2020 22:29:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726071AbgDVW3M (ORCPT ); Wed, 22 Apr 2020 18:29:12 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:58712 "EHLO pb-smtp20.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbgDVW3L (ORCPT ); Wed, 22 Apr 2020 18:29:11 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id BCCFFC4FD5; Wed, 22 Apr 2020 18:29:09 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=mC3D2WXQqxnabF4No7WBVfHURlU=; b=Cty2ZS 0ycT6L+xb3J4OS50vHybsf6Dg27j2Et9G/6AXNCpwsUWcN/5m2l3Oc1jJZq4TDis eFLktcXAypQe8KfTyudInVg+1e29FAJcbVSjdTa+aYL4n75knoCb9/GMTvtAE/Qj TiYHFHpVtAn62O9EKyqtYr69JsUADoG7F4wv0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=LzoMWvX1TAKwvid2X3Pkx9h0PDqzv3Eo ym6m+Ccl/d0canvAXN3Bob31cqK+Mjm0PLZgyBjYFTttVFB55Xjfi8gxWFWgBWY1 bKYzdf0wLE+dOAw+rOfEoAI0rYJ085hoPZBgCsqohI0MRhvPVtSgotAstCL9YMAA 7zc/IE6W5pg= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id AF7AFC4FD4; Wed, 22 Apr 2020 18:29:09 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.74.119.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 92B9EC4FD0; Wed, 22 Apr 2020 18:29:06 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: "Johannes Schindelin via GitGitGadget" Cc: git@vger.kernel.org, Jeff King , "brian m. carlson" , Jonathan Nieder , Ilya Tretyakov , Johannes Schindelin Subject: Re: [PATCH 2/3] credential: teach `credential_from_url()` a non-strict mode References: <1081841b16de31693473e72ff817bed5f0064dda.1587588665.git.gitgitgadget@gmail.com> Date: Wed, 22 Apr 2020 15:29:04 -0700 In-Reply-To: <1081841b16de31693473e72ff817bed5f0064dda.1587588665.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Wed, 22 Apr 2020 20:51:04 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: AD7D24A2-84E8-11EA-A35C-B0405B776F7B-77302942!pb-smtp20.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "Johannes Schindelin via GitGitGadget" writes: > - if (!proto_end || proto_end == url) { > + if (strict && (!proto_end || proto_end == url)) { > if (!quiet) > warning(_("url has no scheme: %s"), url); > return -1; > } > - cp = proto_end + 3; > + cp = proto_end ? proto_end + 3 : url; > at = strchr(cp, '@'); > colon = strchr(cp, ':'); > slash = strchrnul(cp, '/'); > @@ -382,8 +382,10 @@ int credential_from_url_gently(struct credential *c, const char *url, > host = at + 1; > } > > - c->protocol = xmemdupz(url, proto_end - url); > - c->host = url_decode_mem(host, slash - host); > + if (proto_end && proto_end - url > 0) > + c->protocol = xmemdupz(url, proto_end - url); Missing "proto://" under non-strict mode would leave c->protocol NULL (not "") here, as described in [0/3]. Here, slash would be pointing at one of "/?#" at the end of the host and url would be pointing at...? E.g. for "http:///path", URL points at 'h' at the beginning, proto_end points at ':', cp points at the last '/' before "path" and slash is the same as cp. host points at cp as there is no '@' at sign. > + if (slash - url > 0) > + c->host = url_decode_mem(host, slash - host); This wants to make c->host NULL when host is missing, as described in [0/3]. Shouldn't the condition based on "slash - host", though? Other than that, it looks sensible.