Subject: Re: gitweb html validation

From: Junio C Hamano <[email-masked]>
Date: Tue, 15 Nov 2016 16:05:34 -0800

Ralf Thielow <[email-masked]> writes:

> Only block level elements are
> allowed to be inside form tags, according to
> https://www.w3.org/2010/04/xhtml10-strict.html#elem_form
> ...
> I think it's better to just move the <form>-Tag outside of the
> surrounding div?
> Something like this perhaps, I didn't test it myself yet.

That sounds like a sensible update to me (no, I do not run gitweb
myself).  Is this the only <form> we have in the UI, or is it the
only one that is problematic?

> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 7cf68f07b..33d7c154f 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -5531,8 +5531,8 @@ sub git_project_search_form {
>  		$limit = " in '$project_filter/'";
>  	}
>  
> -	print "<div class=\"projsearch\">\n";
>  	print $cgi->start_form(-method => 'get', -action => $my_uri) .
> +	      "<div class=\"projsearch\">\n" .
>  	      $cgi->hidden(-name => 'a', -value => 'project_list')  . "\n";
>  	print $cgi->hidden(-name => 'pf', -value => $project_filter). "\n"
>  		if (defined $project_filter);
> @@ -5544,11 +5544,11 @@ sub git_project_search_form {
>  	                     -checked => $search_use_regexp) .
>  	      "</span>\n" .
>  	      $cgi->submit(-name => 'btnS', -value => 'Search') .
> -	      $cgi->end_form() . "\n" .
>  	      $cgi->a({-href => href(project => undef, searchtext => undef,
>  	                             project_filter => $project_filter)},
>  	              esc_html("List all projects$limit")) . "<br />\n";
> -	print "</div>\n";
> +	print "</div>\n" .
> +	      $cgi->end_form() . "\n";
>  }
>  
>  # entry for given @keys needs filling if at least one of keys in list
> diff --git a/gitweb/static/gitweb.css b/gitweb/static/gitweb.css
> index 321260103..507740b6a 100644
> --- a/gitweb/static/gitweb.css
> +++ b/gitweb/static/gitweb.css
> @@ -539,7 +539,7 @@ div.projsearch {
>  	margin: 20px 0px;
>  }
>  
> -div.projsearch form {
> +form div.projsearch {
>  	margin-bottom: 2px;
>  }
>