All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gitweb: fix base url set if PATH_INFO is used, add a / at the end
@ 2023-02-09 22:26 ` Daniel Abrecht
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Abrecht @ 2023-02-09 22:26 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

In HTML, if there is a base tag like `<base href="/a/b">`, a relative 
URL like
`c/d` will be resolved by the browser as `a/c/d` and not as `a/b/c/d`. 
But with
a base tag like `<base href="/a/b/">` it will result in `a/b/c/d`.

Signed-off-by: Daniel Abrecht <public@danielabrecht.ch>
---
  gitweb/gitweb.perl | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e66eb3d9ba..edcee1652c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -74,6 +74,11 @@ sub evaluate_uri {
  		}
  	}

+	# $base_url is later used in the <base> tag as a URL, if it doesn't 
end in a /
+	# the browser will strip away the last component for relative URLs.
+	# Add the / if it's missing.
+	$base_url .= '/' if not $base_url =~ /\/$/;
+
  	# target of the home link on top of all pages
  	our $home_link = $my_uri || "/";
  }
-- 
2.39.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] gitweb: fix base url set if PATH_INFO is used, add a / at the end.
@ 2023-02-09 22:26 ` Daniel Abrecht
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Abrecht @ 2023-02-03 21:42 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

In HTML, if there is a base tag like `<base href="/a/b">`,
a relative URL like `c/d` will be resolved by the browser as
`a/c/d` and not as `a/b/c/d`. But with a base tag like
`<base href="/a/b/">` it will result in `a/b/c/d`. So by
adding a slash there, the browser should now search the
files at the correct location.

Signed-off-by: Daniel Abrecht <public@danielabrecht.ch>
---
  gitweb/gitweb.perl | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e66eb3d9ba..acb2cce5f6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4217,7 +4217,7 @@ sub git_header_html {
  	# the stylesheet, favicon etc urls won't work correctly with path_info
  	# unless we set the appropriate base URL
  	if ($ENV{'PATH_INFO'}) {
-		print "<base href=\"".esc_url($base_url)."\" />\n";
+		print "<base href=\"".esc_url($base_url)."/\" />\n";
  	}
  	print_header_links($status);

-- 
2.39.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-14 10:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-09 22:26 [PATCH v2] gitweb: fix base url set if PATH_INFO is used, add a / at the end Daniel Abrecht
2023-02-09 23:05 ` Junio C Hamano
2023-02-14 10:15   ` Daniel Abrecht
  -- strict thread matches above, loose matches on Subject: below --
2023-02-03 21:42 [PATCH] " Daniel Abrecht
2023-02-09 22:26 ` [PATCH v2] " Daniel Abrecht
2023-02-06 22:02 ` [PATCH] " Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.