git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: Simplify (and fix) chop_str

From
J.H. <warthog9@eaglescrag.net>
Date
Feb 3, 2010, 18:25 UTC
Message-ID
<4B69BF84.8010400@eaglescrag.net>
In-Reply-To
<201002031228.31324.jnareb@gmail.com>
This looks good to me.
- John 'Warthog9' Hawley
On 02/03/2010 03:28 AM, Jakub Narebski wrote:
Show 66 quoted lines
> From: John 'Warthog9' Hawley <warthog9@kernel.org>
> 
> The chop_str subroutine is meant to be used on strings (such as commit
> description / title) *before* HTML escaping, which means before
> applying esc_html or equivalent.
> 
> Therefore get rid of the failed attempt to always remove full HTML
> entities (like e.g. &amp; or &nbsp;).  It is not necessary (HTML
> entities gets added later), and it can cause chop_str to chop a string
> incorrectly.
> 
> Specifically:
> 
>      API & protocol: support option to force written data immediately to disk
> 
> from http://git.kernel.org/?p=daemon/distsrv/chunkd.git;a=commit;h=3b02f749df2cb1288f345a689d85e7061f507e54
> 
> The short version of the title gets chopped to
> 
>      API ...
> 
> where it should be
> 
>      API & protocol: support option to force written data...
> 
> Noticed-by: John 'Warthog9' Hawley <warthog9@kernel.org>
> Signed-off-by: John 'Warthog9' Hawley <warthog9@kernel.org>
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> ---
> I have retained J.H. authorship of this patch.  I have rewritten
> commit message, added signoffs, and removed all instances of failed
> attempt of removing HTML entities whole, even though only one of them
> is used.
> 
>  gitweb/gitweb.perl |    4 ----
>  1 files changed, 0 insertions(+), 4 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index d0c3ff2..1f6978a 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1330,7 +1330,6 @@ sub chop_str {
>  		$str =~ m/^(.*?)($begre)$/;
>  		my ($lead, $body) = ($1, $2);
>  		if (length($lead) > 4) {
> -			$body =~ s/^[^;]*;// if ($lead =~ m/&[^;]*$/);
>  			$lead = " ...";
>  		}
>  		return "$lead$body";
> @@ -1341,8 +1340,6 @@ sub chop_str {
>  		$str =~ m/^(.*?)($begre)$/;
>  		my ($mid, $right) = ($1, $2);
>  		if (length($mid) > 5) {
> -			$left  =~ s/&[^;]*$//;
> -			$right =~ s/^[^;]*;// if ($mid =~ m/&[^;]*$/);
>  			$mid = " ... ";
>  		}
>  		return "$left$mid$right";
> @@ -1352,7 +1349,6 @@ sub chop_str {
>  		my $body = $1;
>  		my $tail = $2;
>  		if (length($tail) > 4) {
> -			$body =~ s/&[^;]*$//;
>  			$tail = "... ";
>  		}
>  		return "$body$tail";
Previous: Jakub NarebskiNext: Junio C Hamano
Message 7 of 9 in “gitweb misc fixes mkII”
  1. 0/2 gitweb misc fixes mkIIJohn 'Warthog9' Hawley, Feb 2, 2010
  2. 1/2 gitweb: Add an option to force version matchJohn 'Warthog9' Hawley, Feb 2, 2010
  3. 2/2 gitweb: Fix chop_str to allow for & characters in stringsJohn 'Warthog9' Hawley, Feb 2, 2010
  4. Jakub NarebskiFeb 2, 2010
  5. J.H.Feb 2, 2010
  6. gitweb: Simplify (and fix) chop_strJakub Narebski, Feb 3, 2010
  7. J.H.Feb 3, 2010
  8. Junio C HamanoFeb 2, 2010
  9. Jakub NarebskiFeb 2, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.