BUGREPORT: Tab to space expanding bug

Jozef Matula Jozef.Matula at iblsoft.com
Wed Dec 8 00:35:37 PST 2004


Hello,

We use CVSweb version 3:3.0.2-2 under Debian Linux unstable distribution.

We found a bug in algorithm of expanding tabs into spaces in main CGI Perl 
script:
  - $1 was not in expansiong so, after multiple tab expansions text before 
tabs was discarded
  - expanding with less than $ts spaces was also incorrect, because $1 as (.*) 
was matching longest string, including any previous NOT EXPANDED tabs.

I think, this patch is fixing it.

--- cvsweb      2004-11-17 02:23:53.000000000 +0100
+++ /usr/lib/cgi-bin/cvsweb     2004-12-08 09:22:33.000000000 +0100
@@ -1579,7 +1579,7 @@
   if (defined($ts)) {

     # Expand tabs
-    1 while s/(.*)(\t+)/' ' x (length($2) * $ts - length($1) % $ts)/e;
+       1 while s/(.*?)(\t+)/$1 . ' ' x (length($2) * $ts - length($1) % 
$ts)/e;
   }

   # replace <tab> and <space> (\001 is to protect us from htmlify)

Best regards,

Jozef Matula

-- 
Jozef MATULA (Jozef.Matula at iblsoft.com)
IBL Software Engineering, http://www.iblsoft.com  
Mierova 103, 82105 Bratislava, Slovakia
Tel: +421-2-43427227, fax: +421-2-43427214



More information about the freebsd-cvsweb mailing list