List for cgit developers and users
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: samuel@kodafritt.se, cgit@lists.zx2c4.com
Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>
Subject: [PATCH v2] config: make empty js= omit script tag
Date: Tue, 10 Jan 2023 17:53:40 +0100	[thread overview]
Message-ID: <20230110165340.27837-1-Jason@zx2c4.com> (raw)
In-Reply-To: <CAHmME9pP8JFJ94mjnL_60wNNA9HB2fXqopEh6ZN0=s1fZjkUUA@mail.gmail.com>

From: Samuel Lidén Borell <samuel@kodafritt.se>

According to the cgitrc man page, an empty js= value should cause the
script tag to be omitted. But instead, a script tag with an empty URL
is emitted. The same applies to css. So, skip emitting a tag if the
specified string is empty.

Signed-off-by: Samuel Lidén Borell <samuel@kodafritt.se>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 ui-shared.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ui-shared.c b/ui-shared.c
index 11aed19..baea6f2 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -770,6 +770,10 @@ static void print_rel_vcs_link(const char *url)
 
 static int emit_css_link(struct string_list_item *s, void *arg)
 {
+	/* Do not emit anything if css= is specified. */
+	if (s && *s->string == '\0')
+		return 0;
+
 	html("<link rel='stylesheet' type='text/css' href='");
 	if (s)
 		html_attr(s->string);
@@ -782,6 +786,10 @@ static int emit_css_link(struct string_list_item *s, void *arg)
 
 static int emit_js_link(struct string_list_item *s, void *arg)
 {
+	/* Do not emit anything if js= is specified. */
+	if (s && *s->string == '\0')
+		return 0;
+
 	html("<script type='text/javascript' src='");
 	if (s)
 		html_attr(s->string);
-- 
2.39.0


  reply	other threads:[~2023-01-10 16:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 11:38 [PATCH] config: Make " Samuel Lidén Borell
2023-01-10 16:50 ` Jason A. Donenfeld
2023-01-10 16:53   ` Jason A. Donenfeld [this message]
2023-01-10 18:53     ` [PATCH v2] config: make " Samuel Lidén Borell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230110165340.27837-1-Jason@zx2c4.com \
    --to=jason@zx2c4.com \
    --cc=cgit@lists.zx2c4.com \
    --cc=samuel@kodafritt.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).