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

[PATCH] gitweb: Measure offsets against UTF-8 flagged string

From
Shin Kojima <shin@kojima.org>
Date
May 1, 2018, 06:40 UTC
Message-ID
<20180501064015.59977-1-shin@kojima.org>

Offset positions should not be counted by byte length, but by actual character length.

>    5183 	# We need to untabify lines before split()'ing them;
>    5184 	# otherwise offsets would be invalid.

Horizontal tab is not the only case we need to consider. Please excuse me for using your name here, but the following URL can not find "match" occurances while using `git-instaweb` on the git repository.

    http://127.0.0.1:1234/?p=.git&a=search&h=HEAD&st=grep&s=Nar%C4%99bski
Signed-off-by: Shin Kojima <shin@kojima.org>
---
 gitweb/gitweb.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2594a4bad..a5a9093a1 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1697,7 +1697,7 @@ sub unquote {
 
 # escape tabs (convert tabs to spaces)
 sub untabify {
-	my $line = shift;
+	my $line = to_utf8(shift);
 
 	while ((my $pos = index($line, "\t")) != -1) {
 		if (my $count = (8 - ($pos % 8))) {
-- 
2.17.0
Next: Junio C Hamano
Message 1 of 6 in “gitweb: Measure offsets against UTF-8 flagged string”
  1. gitweb: Measure offsets against UTF-8 flagged stringShin Kojima, May 1, 2018
  2. Junio C HamanoMay 2, 2018
  3. Shin KojimaMay 2, 2018
  4. Jakub NarebskiMay 3, 2018
  5. Shin KojimaMay 3, 2018
  6. Junio C HamanoMay 4, 2018

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.