Fossil SCM
Duplicate slashes from base URL in repolist
e4d8a23d1fbd79c…
· opened 5 years, 5 months ago
- Type
- Code_Defect
- Priority
- Immediate
- Severity
- Important
- Resolution
- Fixed
- Subsystem
- —
- Created
- Oct. 12, 2020 7:06 a.m.
- What do I see:
Run fossil serve in repolist mode with a reverse proxy:
fossil serve --nossl --baseurl http://fossil.host.xyz/ --repolist ./
Click a repo wj to open and login, the URL is:
http://fossil.host.xyz//fossil-repos/wj/login?g=/fossil-repos/wj/home
At setup page, the URL is:
http://fossil.host.xyz//fossil-repos/wj/setup_ulist
The double // returns a valid page.
- What do I expect:
There is no // in the URL.
- Analysis:
The reason is fossil expects at least three / in the URL (set_base_url() in main.c), e.g. http://host/path. However, if the URL is http://host.path.domain, the code that checks for three / fails.
Later code that constructs URL assumes no ending /. e.g. repo_list_page() in repolist.c:
@ <base href="%s(g.zBaseURL)/" />
- Solution
Add a special check for two / and no ending /.
I have a patch and would you mind to review it?
Thank you!
Comments (1)
- What do I see:
Run fossil serve in repolist mode with a reverse proxy:
fossil serve --nossl --baseurl http://fossil.host.xyz/ --repolist ./
Click a repo wj to open and login, the URL is:
http://fossil.host.xyz//fossil-repos/wj/login?g=/fossil-repos/wj/home
At setup page, the URL is:
http://fossil.host.xyz//fossil-repos/wj/setup_ulist
The double // returns a valid page.
- What do I expect:
There is no // in the URL.
- Analysis:
The reason is fossil expects at least three / in the URL (set_base_url() in main.c), e.g. http://host/path. However, if the URL is http://host.path.domain, the code that checks for three / fails.
Later code that constructs URL assumes no ending /. e.g. repo_list_page() in repolist.c:
@ <base href="%s(g.zBaseURL)/" />
- Solution
Add a special check for two / and no ending /.
I have a patch and would you mind to review it?
Thank you!