Re: [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:18

Jakub Narebski [off-list ref] writes:
quoted hunk
The default (in gitweb/Makefile) is to use relative paths for gitweb
static files, e.g. "static/gitweb.css" for GITWEB_CSS.  But the
configuration for Plack::Middleware::Static in plackup_conf assumed
that static files must be absolute paths starting with "/gitweb/"
prefix which had to be stripped, e.g. "/gitweb/static/gitweb.css".
This in turn caused web server run by "git instaweb --httpd=plackup"
to not access static files (e.g. CSS) correctly.

This is a minimal fixup, making 'plackup' web server in git-instaweb
work with default gitweb build configuration.

Reported-by: Tadeusz Sośnierz <redacted>
Signed-off-by: Jakub Narebski <redacted>
---
The regexp is probably too strict: qr{^/static/} should be enough,
but I didn't want to change too much at once.

This bug was not noticed because we don't have any test for
git-instaweb, not mentioning tests for all web servers supported.  And
the fact that I was checking "git instaweb -httpd=plackup" against
gitweb.cgi built with custom configuration (including the fact that
GITWEB_CSS="/gitweb/static/gitweb.css").

tadzik, does that fix the issue you noticed?

Junio, could you apply this before 1.7.4?  Thanks in advance.

 git-instaweb.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 10fcebb..bb57d81 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -549,7 +549,7 @@ my \$app = builder {
 	};
 	# serve static files, i.e. stylesheet, images, script
 	enable 'Static',
-		path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
+		path => qr{^/static/.*(?:js|css|png)\$},
I wonder if you meant qr{^/static/.*\\.(?:js|css|png)\$} here, to make
sure that these three tokens are file suffixes, not just random
substring.
 		root => "$root/",
 		encoding => 'utf-8'; # encoding for 'text/plain' files
 	# convert CGI application to PSGI app
-- 
1.7.3

Re: [BUGFIX PATCH 1/4] git-instaweb: Fix issue with static files for 'plackup' server

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:50:18

On Thu, 30 Dec 2010, Junio C Hamano wrote:
Jakub Narebski [off-list ref] writes:
quoted
The default (in gitweb/Makefile) is to use relative paths for gitweb
static files, e.g. "static/gitweb.css" for GITWEB_CSS.  But the
configuration for Plack::Middleware::Static in plackup_conf assumed
that static files must be absolute paths starting with "/gitweb/"
prefix which had to be stripped, e.g. "/gitweb/static/gitweb.css".
This in turn caused web server run by "git instaweb --httpd=plackup"
to not access static files (e.g. CSS) correctly.

This is a minimal fixup, making 'plackup' web server in git-instaweb
work with default gitweb build configuration.

Reported-by: Tadeusz Sośnierz <redacted>
Signed-off-by: Jakub Narebski <redacted>
---
The regexp is probably too strict: qr{^/static/} should be enough,
but I didn't want to change too much at once.
[...]
quoted
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 10fcebb..bb57d81 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -549,7 +549,7 @@ my \$app = builder {
 	};
 	# serve static files, i.e. stylesheet, images, script
 	enable 'Static',
-		path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
+		path => qr{^/static/.*(?:js|css|png)\$},
I wonder if you meant qr{^/static/.*\\.(?:js|css|png)\$} here, to make
sure that these three tokens are file suffixes, not just random
substring.
Yes, it should be qr{^/static/.*\\.(?:js|css|png)\$} though as I said:
"The regexp is probably too strict: qr{^/static/} should be enough,"

-- 
Jakub Narebski
Poland
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help