Re: [PATCH 1/3] urlmatch: normalize ssh and ftp default ports

Ben Knoble <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
> Le 24 juil. 2026 à 09:41, Fabian Pottbäcker <[email protected]> a écrit :
> 
> These protocols are still supported by git and have well known
> default ports. This leaves FTPS, which does not have one default
> port.
> 
> Signed-off-by: Fabian Pottbäcker <[email protected]>
> ---
> t/unit-tests/u-urlmatch-normalization.c |  9 +++++++++
> urlmatch.c                              | 16 ++++++++++++----
> 2 files changed, 21 insertions(+), 4 deletions(-)
> 

[snip]

> diff --git a/urlmatch.c b/urlmatch.c
> index 20bc2d009c..0c2ddf2e40 100644
> --- a/urlmatch.c
> +++ b/urlmatch.c
> @@ -274,12 +274,20 @@ static char *url_normalize_1(const char *url, struct url_info *out_info, bool al
>        if (url == slash_ptr) {
>            /* Skip ":" port with no number, it's same as default */
>        } else if (slash_ptr - url == 2 &&
> -               starts_with(norm.buf, "http:") &&
> -               !strncmp(url, "80", 2)) {
> +                starts_with(norm.buf, "ftp:") &&
> +                !strncmp(url, "21", 2)) {
> +            /* Skip http :21 as it's the default */
> +        } else if (slash_ptr - url == 2 &&
> +                starts_with(norm.buf, "ssh:") &&
> +                !strncmp(url, "22", 2)) {
> +            /* Skip http :22 as it's the default */
> +        } else if (slash_ptr - url == 2 &&
> +                starts_with(norm.buf, "http:") &&
> +                !strncmp(url, "80", 2)) {
>            /* Skip http :80 as it's the default */
>        } else if (slash_ptr - url == 3 &&
> -               starts_with(norm.buf, "https:") &&
> -               !strncmp(url, "443", 3)) {
> +                starts_with(norm.buf, "https:") &&
> +                !strncmp(url, "443", 3)) {
>            /* Skip https :443 as it's the default */
>        } else {
>            /*
> --
> 2.50.1 (Apple Git-155)

Just offhand, not commenting on the rest of the series : the comments look wrong for ftp, ssh to me.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.