List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] config: Make empty js= omit script tag
@ 2023-01-07 11:38 Samuel Lidén Borell
  2023-01-10 16:50 ` Jason A. Donenfeld
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Lidén Borell @ 2023-01-07 11:38 UTC (permalink / raw)
  To: cgit

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

Hi,

Here's a patch to make empty js= values in cgitrc work as documented.

I'm sending it gzipped, because the mail server rejects it otherwise due to HTML in the patch.

Regards,
Samuel

[-- Attachment #2: 0001-config-Make-empty-js-omit-script-tag.patch.gz --]
[-- Type: application/gzip, Size: 789 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] config: Make empty js= omit script tag
  2023-01-07 11:38 [PATCH] config: Make empty js= omit script tag Samuel Lidén Borell
@ 2023-01-10 16:50 ` Jason A. Donenfeld
  2023-01-10 16:53   ` [PATCH v2] config: make " Jason A. Donenfeld
  0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2023-01-10 16:50 UTC (permalink / raw)
  To: samuel; +Cc: cgit

Hi Samuel,

This also needs to be done for css. I'll send a v2 and apply it.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] config: make empty js= omit script tag
  2023-01-10 16:50 ` Jason A. Donenfeld
@ 2023-01-10 16:53   ` Jason A. Donenfeld
  2023-01-10 18:53     ` Samuel Lidén Borell
  0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2023-01-10 16:53 UTC (permalink / raw)
  To: samuel, cgit; +Cc: Jason A . Donenfeld

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] config: make empty js= omit script tag
  2023-01-10 16:53   ` [PATCH v2] config: make " Jason A. Donenfeld
@ 2023-01-10 18:53     ` Samuel Lidén Borell
  0 siblings, 0 replies; 4+ messages in thread
From: Samuel Lidén Borell @ 2023-01-10 18:53 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: cgit

Thanks :) Confirming that your v2 of the patch works. Tested both js and css

Regards,
Samuel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-10 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-07 11:38 [PATCH] config: Make empty js= omit script tag Samuel Lidén Borell
2023-01-10 16:50 ` Jason A. Donenfeld
2023-01-10 16:53   ` [PATCH v2] config: make " Jason A. Donenfeld
2023-01-10 18:53     ` Samuel Lidén Borell

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).