[PATCH 4/5] ui: Fix bad value for attribute action on form elements

Juuso Lapinlampi wub at partyvan.eu
Thu May 12 21:36:29 CEST 2016


On Thu, May 12, 2016 at 09:27:14PM +0200, Jason A. Donenfeld wrote:
> Good idea with the Chrome developer tools. I just tried it myself, and
> no it doesn't work.
> 
> The switch branch form works with https://git.zx2c4.com/zmusic-ng/ and
> fails with https://git.zx2c4.com/zmusic-ng which is what I suspected.
> 
> It turns out action is not required either, and when omitted means
> "this page", which is what we want and what I originally suggested:
> 
> https://www.w3.org/TR/html5/forms.html#attr-fs-action

You're right, it does fail. Thanks for testing.

The "diff options" in commit diff page also uses `action='.'`. That also
creates an issue.

The (more) relevant WHATWG specification about action is there:
https://html.spec.whatwg.org/multipage/forms.html#attr-fs-action

So the action is optional.

Would this patch work to fix the validation and related bugs?

diff --git a/ui-diff.c b/ui-diff.c
index 52ed942..edee793 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -340,7 +340,7 @@ void cgit_print_diff_ctrls(void)

        html("<div class='cgit-panel'>");
        html("<b>diff options</b>");
-       html("<form method='get' action='.'>");
+       html("<form method='get'>");
        cgit_add_hidden_formfields(1, 0, ctx.qry.page);
        html("<table>");
        html("<tr><td colspan='2'/></tr>");
diff --git a/ui-shared.c b/ui-shared.c
index 770b685..2c88b72 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -937,7 +937,7 @@ static void print_header(void)
                cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);
                if (ctx.env.authenticated) {
                        html("</td><td class='form'>");
-                       html("<form method='get' action=''>\n");
+                       html("<form method='get'>\n");
                        cgit_add_hidden_formfields(0, 1, ctx.qry.page);
                        html("<select name='h' onchange='this.form.submit();'>\n");
                        for_each_branch_ref(print_branch_option, ctx.qry.head);
diff --git a/ui-stats.c b/ui-stats.c
index 8cd9178..7acd358 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -389,7 +389,7 @@ void cgit_show_stats(void)
        cgit_print_layout_start();
        html("<div class='cgit-panel'>");
        html("<b>stat options</b>");
-       html("<form method='get' action=''>");
+       html("<form method='get'>");
        cgit_add_hidden_formfields(1, 0, "stats");
        html("<table><tr><td colspan='2'/></tr>");
        if (ctx.repo->max_stats > 1) {


More information about the CGit mailing list