From fa871b31f6c3309d3c3d0b4bebcd5b5b62706f0a Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 29 Aug 2026 15:50:14 -1000 Subject: Point clone rows at a url a browser can follow --- source/ui-shared.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index 85712bf..5cf9428 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -317,8 +317,26 @@ static void print_rel_date(time_t t, int tz, double count, const char *class, htmlf("'>%.0f %s", count, suffix); } +/* + * Whether a clone url opens with a URI scheme. The scp form git@host:path + * has none, and a link element's href must hold a URI, so that form stays + * out of the document head. + */ +static int has_uri_scheme(const char *url) +{ + const char *p = url; + + if (!isalpha((unsigned char)*p)) + return 0; + while (isalnum((unsigned char)*p) || *p == '+' || *p == '-' || *p == '.') + p++; + return *p == ':'; +} + static void print_rel_vcs_link(const char *url) { + if (!has_uri_scheme(url)) + return; html("url); + } + + if (colspan) + htmlf("", colspan); + else + html(""); + html(""); + html_txt(url); + html("\n"); + free(fallback); +} + void cgit_add_hidden_formfields(int incl_head, int incl_search, const char *page) { -- cgit v2.8.0