From: Christian Couder Date: Tue, 19 May 2026 15:25:03 GMT Subject: Re: [PATCH v2 6/8] promisor-remote: trust known remotes matching acceptFromServerUrl Message-ID: In-Reply-To: <87qzninlb4.fsf@toon--20250203-5JQV3.mail-host-address-is-not-set> On Mon, May 11, 2026 at 3:11 PM Toon Claes wrote: > > Christian Couder writes: > > > +static bool match_one_url(const struct url_info *pi, const struct url_info *ui) > > +{ > > + const char *pat = pi->url; > > + const char *url = ui->url; > > + char *p_str, *u_str; > > + bool res; > > + > > + /* > > + * Schemes must match exactly. They are case-folded by > > + * url_normalize(), so strncmp() suffices. > > + */ > > + if (pi->scheme_len != ui->scheme_len || strncmp(pat, url, pi->scheme_len)) > > + return false; > > + > > + /* > > + * Ports must match exactly. url_normalize() strips default > > + * ports (like 443 for https), so length and content > > + * comparisons are sufficient. > > + */ > > + if (pi->port_len != ui->port_len || > > + strncmp(pat + pi->port_off, url + ui->port_off, pi->port_len)) > > + return false; > > + > > + /* > > + * Match host and path separately to prevent a '*' in the host > > + * portion of the pattern from matching across the '/' > > + * boundary into the path. Use WM_PATHNAME for the host so '*' > > + * cannot cross '/' there, and 0 for the path so '*' can still > > + * match multi-level paths. > > + */ > > + > > + p_str = xstrndup(pat + pi->host_off, pi->host_len); > > + u_str = xstrndup(url + ui->host_off, ui->host_len); > > + res = !wildmatch(p_str, u_str, WM_PATHNAME); > > + free(p_str); > > + free(u_str); > > + > > + if (!res) > > I feel it's a bit confusing your negating the result from wildmatch() > to negate it here again? Maybe keep using the int return value, or > rename the variable to 'matches' ? I have simplified this in the v3. Thanks.