gitweb: make static files accessible with PATH_INFO
Gitweb links to a number of static files such as CSS stylesheets, favicon or the git logo. When, such as with the default Makefile, the paths to these files are relative (i.e. doesn't start with a "/"), the files become inaccessible in any view other tha project list and summary page if gitweb is invoked with a non-empty PATH_INFO. Fix this by adding a <base> element pointing to the script's own URL, which ensure that all relative paths will be resolved correctly. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Giuseppe Bilotta committed
Jan 31, 2009 at 02:31 UTC
c3254aeecf89a620db262480a7c424e7607f1e2a
1 file changed
+5
gitweb/gitweb.perl
+5
@@ -2901,6 +2901,11 @@ sub git_header_html {
2901
<meta name="robots" content="index, nofollow"/>
2902
<title>$title</title>
2903
EOF
2904
+# the stylesheet, favicon etc urls won't work correctly with path_info unless we
2905
+# set the appropriate base URL
2906
+ if ($ENV{'PATH_INFO'}) {
2907
+ print '<base href="'.esc_url($my_url).'" />\n';
2908
+ }
2909
# print out each stylesheet that exist
2910
if (defined $stylesheet) {
2911
#provides backwards capability for those people who define style sheet in a config file