Search Box (from a nested Repository) doesn't work within Tomcat #407

Closed
gitblit opened this Issue Aug 12, 2015 · 6 comments

Comments

Projects
None yet
2 participants
@gitblit
Owner

gitblit commented Aug 12, 2015

Originally reported on Google Code with ID 111

What steps will reproduce the problem?
1. Install gitblit on Tomcat (with context of /gitblit)
1b. I'm using ALLOW_ENCODED_SLASH=true
2. Pick a nested repository (e.g. repos/MyRepo.git)
3. Go into that Repository, and execute any search

What is the expected output? What do you see instead?
It should forward to the proper Search page.  However, wicket is redirecting to something
like http://localhost:8080/gitblit/summary/lucene/?s=john&r=repos/MyRepo.git&st=COMMIT

Notice summary is still in the path.

Debugging through wicket, the redirect URL is ../lucene... but should be ../../lucene.

I've only seen this issue with nested repositories, on tomcat.  I've tried with repositories
on "main" on tomcat, it's fine.  I've tested with nested repositories on GitBlit Go
and it seems fine as well.

What version of the product are you using? On what operating system?
1.0.0 on Tomcat on windows or linux

I'm attempting to find a solution, but my knowledge of Wicket is minimal.  Please assist.

Reported by johnedc on 2012-07-20 16:02:40

@gitblit

This comment has been minimized.

Show comment
Hide comment
@gitblit

gitblit Aug 12, 2015

Owner
Interesting.  I confirm the behavior in Tomcat 6 and Tomcat 7.  I also confirm that
Jetty (GO) does not have this same problem - even after setting the context.

I have 3 solutions for you.

1. Comment-out line 114 of com.gitblit.wicket.GitblitWebApp and rebuild.  This uses
query parameters to load the lucene search page instead of resolving relative links
to the search page (../../).
2. web.mountParameters=false (no rebuild required)
3. web.forwardSlashCharacter=! (no rebuild required)

Reported by James.Moger on 2012-07-20 18:07:57

  • Status changed: Accepted
Owner

gitblit commented Aug 12, 2015

Interesting.  I confirm the behavior in Tomcat 6 and Tomcat 7.  I also confirm that
Jetty (GO) does not have this same problem - even after setting the context.

I have 3 solutions for you.

1. Comment-out line 114 of com.gitblit.wicket.GitblitWebApp and rebuild.  This uses
query parameters to load the lucene search page instead of resolving relative links
to the search page (../../).
2. web.mountParameters=false (no rebuild required)
3. web.forwardSlashCharacter=! (no rebuild required)

Reported by James.Moger on 2012-07-20 18:07:57

  • Status changed: Accepted
@gitblit

This comment has been minimized.

Show comment
Hide comment
@gitblit

gitblit Aug 12, 2015

Owner
Thanks a million...I never would have found that gem.  I'm going with #2, but I'll keep
it in the back of my mind for later to see if there's a generic coding solution (as
I generally like the REST-style URLs).

Reported by johnedc on 2012-07-20 18:24:16

Owner

gitblit commented Aug 12, 2015

Thanks a million...I never would have found that gem.  I'm going with #2, but I'll keep
it in the back of my mind for later to see if there's a generic coding solution (as
I generally like the REST-style URLs).

Reported by johnedc on 2012-07-20 18:24:16

@gitblit

This comment has been minimized.

Show comment
Hide comment
@gitblit

gitblit Aug 12, 2015

Owner
Choice 3 keeps you closer to REST-style.

Reported by James.Moger on 2012-07-20 18:33:28

Owner

gitblit commented Aug 12, 2015

Choice 3 keeps you closer to REST-style.

Reported by James.Moger on 2012-07-20 18:33:28

@gitblit

This comment has been minimized.

Show comment
Hide comment
@gitblit

gitblit Aug 12, 2015

Owner
I've spent a bunch of time trying to understand why there is a difference between Jetty
and Tomcat on this point.  As you know Gitblit development is not well-equipped to
debug Tomcat and I am tired of subclassing Wicket components and adding console logging
to discover where the bug lies.

I do know that the relative path of the Lucene page (../lucene) is correct.  The problem
is that by the end of page generation, the url appears to be based on the servlet path
including mounted repository parameters, instead of just the servlet path.  This leads
you to conclude that the relative path should be "../../" (which seems right) but that
is not actually correct.  Somehow Wicket-Tomcat is counting the repository parameter
forward-slashes as part of the path.  If you use ! instead of / this all goes away.
 A number of times I thought the solution was within my grasp... but I keep missing
it and it's time to move on.

Instead of using the normal class/page-parameters methods to redirect to the Lucene
page, I am using Wicket to generate an absolute URL and I redirect to it.  It is not
as elegant as using the normal api methods, but it works for both Jetty and Tomcat.
 It also works behind a reverse proxy.  Perhaps in the future I will revisit this issue
(but I doubt it).  :)

Reported by James.Moger on 2012-08-09 21:21:49

  • Status changed: Queued
  • Labels added: Milestone-1.0.1
Owner

gitblit commented Aug 12, 2015

I've spent a bunch of time trying to understand why there is a difference between Jetty
and Tomcat on this point.  As you know Gitblit development is not well-equipped to
debug Tomcat and I am tired of subclassing Wicket components and adding console logging
to discover where the bug lies.

I do know that the relative path of the Lucene page (../lucene) is correct.  The problem
is that by the end of page generation, the url appears to be based on the servlet path
including mounted repository parameters, instead of just the servlet path.  This leads
you to conclude that the relative path should be "../../" (which seems right) but that
is not actually correct.  Somehow Wicket-Tomcat is counting the repository parameter
forward-slashes as part of the path.  If you use ! instead of / this all goes away.
 A number of times I thought the solution was within my grasp... but I keep missing
it and it's time to move on.

Instead of using the normal class/page-parameters methods to redirect to the Lucene
page, I am using Wicket to generate an absolute URL and I redirect to it.  It is not
as elegant as using the normal api methods, but it works for both Jetty and Tomcat.
 It also works behind a reverse proxy.  Perhaps in the future I will revisit this issue
(but I doubt it).  :)

Reported by James.Moger on 2012-08-09 21:21:49

  • Status changed: Queued
  • Labels added: Milestone-1.0.1
@gitblit

This comment has been minimized.

Show comment
Hide comment
@gitblit

gitblit Aug 12, 2015

Owner

Reported by James.Moger on 2012-08-20 02:06:35

  • Labels added: Milestone-1.1.0
  • Labels removed: Milestone-1.0.1
Owner

gitblit commented Aug 12, 2015

Reported by James.Moger on 2012-08-20 02:06:35

  • Labels added: Milestone-1.1.0
  • Labels removed: Milestone-1.0.1
@gitblit

This comment has been minimized.

Show comment
Hide comment
@gitblit

gitblit Aug 12, 2015

Owner
Fix/change released in 1.1.0.

Reported by James.Moger on 2012-08-25 12:20:42

  • Status changed: Fixed
Owner

gitblit commented Aug 12, 2015

Fix/change released in 1.1.0.

Reported by James.Moger on 2012-08-25 12:20:42

  • Status changed: Fixed

@gitblit gitblit closed this Aug 12, 2015

@fzs fzs modified the milestone: 1.1.0 Dec 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment