# [PATCHv2] gitweb: make static files accessible with PATH_INFO

3 messages from 2009-01-26 to 2009-01-28. Participants: Giuseppe Bilotta, Jakub Narebski.
Thread: https://gitlist.dev/t/17370

## Giuseppe Bilotta, 2009-01-26 12:45

Subject: [PATCHv2] gitweb: make static files accessible with PATH_INFO
Message-ID: <1232973937-23875-1-git-send-email-giuseppe.bilotta@gmail.com>
URL: https://gitlist.dev/e/1232973937-23875-1-git-send-email-giuseppe.bilotta%40gmail.com

```
When PATH_INFO is defined, static files such as the defalt CSS or the
shortcut icon are not accessible beyond the summary page (e.g. in
shortlog or commit view).

Fix this by adding a <base> tag pointing to the script base URL.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
It's sick that $cgi->url() has no way to print the script base url
without path_info information (or that, if it has, it's very well
hidden).

 gitweb/gitweb.perl |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 931db4f..910da35 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2901,6 +2901,14 @@ sub git_header_html {
 <meta name="robots" content="index, nofollow"/>
 <title>$title</title>
 EOF
+# the stylesheet, favicon etc urls won't work correctly with path_info unless we set the appropriate base URL
+	if ($ENV{'PATH_INFO'}) {
+		my $base = $my_uri;
+		my $sname = $ENV{'SCRIPT_NAME'};
+		$base =~ s,\Q$sname\E$,,;
+		$base .= "/";
+		print "<base href=\"$base\"/>\n";
+	}
 # print out each stylesheet that exist
 	if (defined $stylesheet) {
 #provides backwards capability for those people who define style sheet in a config file
-- 
1.5.6.5

```

## Jakub Narebski, 2009-01-28 00:20

Subject: Re: [PATCHv2] gitweb: make static files accessible with PATH_INFO
Message-ID: <200901280120.38985.jnareb@gmail.com>
URL: https://gitlist.dev/e/200901280120.38985.jnareb%40gmail.com
In-Reply-To: <1232973937-23875-1-git-send-email-giuseppe.bilotta@gmail.com>

```
On Mon, 26 Jan 2009, Giuseppe Bilotta wrote:

> It's sick that $cgi->url() has no way to print the script base url
> without path_info information (or that, if it has, it's very well
> hidden).

Actually:

http://localhost/cgi-bin/gitweb/printenv.cgi/path/info?query=a;string=b;c=c;c=a

url(-absolute=>1)  = /cgi-bin/gitweb/printenv.cgi
url(-relative=>1)  = /cgi-bin/gitweb/printenv.cgi
url(-full=>1)      = http://localhost/cgi-bin/gitweb/printenv.cgi
url(-path_info=>1) = http://localhost/cgi-bin/gitweb/printenv.cgi/path/info
url(-query=>1)     = http://localhost/cgi-bin/gitweb/printenv.cgi?query=a;string=b;c=c;c=a
url(-base=>1)      = http://localhost 

$ENV{'SCRIPT_NAME'} = /cgi-bin/gitweb/printenv.cgi
$ENV{'PATH_INFO'}   = /path/info

With CGI.pm version 3.10
-- 
Jakub Narebski
Poland

```

## Giuseppe Bilotta, 2009-01-28 00:33

Subject: Re: [PATCHv2] gitweb: make static files accessible with PATH_INFO
Message-ID: <cb7bb73a0901271633meb3be90k173ec3cf1a6e33de@mail.gmail.com>
URL: https://gitlist.dev/e/cb7bb73a0901271633meb3be90k173ec3cf1a6e33de%40mail.gmail.com
In-Reply-To: <200901280120.38985.jnareb@gmail.com>

```
On Wed, Jan 28, 2009 at 1:20 AM, Jakub Narebski <jnareb@gmail.com> wrote:
> On Mon, 26 Jan 2009, Giuseppe Bilotta wrote:
>
>> It's sick that $cgi->url() has no way to print the script base url
>> without path_info information (or that, if it has, it's very well
>> hidden).
>
> Actually:
>
> http://localhost/cgi-bin/gitweb/printenv.cgi/path/info?query=a;string=b;c=c;c=a
>
> url(-absolute=>1)  = /cgi-bin/gitweb/printenv.cgi
> url(-relative=>1)  = /cgi-bin/gitweb/printenv.cgi
> url(-full=>1)      = http://localhost/cgi-bin/gitweb/printenv.cgi
> url(-path_info=>1) = http://localhost/cgi-bin/gitweb/printenv.cgi/path/info
> url(-query=>1)     = http://localhost/cgi-bin/gitweb/printenv.cgi?query=a;string=b;c=c;c=a
> url(-base=>1)      = http://localhost
>
> $ENV{'SCRIPT_NAME'} = /cgi-bin/gitweb/printenv.cgi
> $ENV{'PATH_INFO'}   = /path/info

Yeah, but all of these have the script name in it, I was looking for
one without the script name. But more about this in the other reply.

-- 
Giuseppe "Oblomov" Bilotta

```
