mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
[Bug] User dashboard doesn't have forward-slashes unlike other pages, resulting in incorrectly generated "pagination" navigation links for subpath-enabled instances #12574
Closed
opened 2025-11-02 10:14:31 -06:00 by GiteaMirror
·
25 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.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v1.4.0
v1.4.0-rc3
v1.4.0-rc2
v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#12574
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @OdinVex on GitHub (Mar 2, 2024).
Description
After logging in (at the user dashboard), users are presented with their commit history and such...but the navigation at the bottom does not use correct links (subpath issue). Everywhere else they appear to be correct, but here is the actual HTML (cleaned up for sake of posting):
There is a missing forward-slash after
SUBPATH. All other links generated by Gitea appear to be correct (/SUBPATH/).I believe the issue is in paginate.tmpl, the way links are generated using
{{$.Link}}instead of{{$.Link}}/or perhaps{{AppSubUrl}}/? I don't do Go. All of that paginating uses broken linkage.I do use Forgejo, but the issue is present in Gitea as well.
Gitea Version
1.21.3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Docker behind a reverse-proxy with a subpath.
Database
MySQL/MariaDB
@OdinVex commented on GitHub (Mar 2, 2024):
Without the forward-slash users are told to login again (Gitea destroys the session maybe?).
@wxiaoguang commented on GitHub (Mar 2, 2024):
If I understand correctly, that's by design. In Gitea, the URLs are always considered to equal no matter they have trailing slash or not.
So maybe you could make your reverse proxy to serve
http://.../subpathashttp://.../subpath/? Redirect to the "slashed" path?I think the "login" (cookie) problem is related to the cookie path. The cookie is only set on "/subpath/" IIRC ......
I think there are some design problems for the "subpath" and "cookie", maybe it needs some improvements ....
@wxiaoguang commented on GitHub (Mar 2, 2024):
After looking into the problem:
{{.Link}}/other-path. It would cause double-slashes if there is a trailing slash://other-path: it is even worse, because browsers would use it ashttps://other-path./subpath//other-path: not a good URL path ....The workaround could be: make reverse proxy always redirect all "/subpath?..." requests to "/subpath/?...."To completely fix the problem, it needs more designs & improvements ..... not that easy by a simple fix.Update: I think case 2 is the root problem.
@wxiaoguang commented on GitHub (Mar 2, 2024):
Oops .... I found the root problem now. That's my fault (regression of #24107)
-> Fix incorrect cookie path for AppSubURL #29534
@OdinVex commented on GitHub (Mar 2, 2024):
To reclarify, this issue is about pagination, in the template for links generated (First, Previous, #, Next, Last...) on the user dashboard.
Edit: Pagination is not using
{{.Link}}/, it is using{{$.Link}}without a forward-slash, as I mentioned. I think those need updating.@wxiaoguang commented on GitHub (Mar 2, 2024):
More details in https://github.com/go-gitea/gitea/pull/29534#issuecomment-1974851486
If you focus on "fixing the trailing slash", I could remove the "fix" operation from that PR, and keep this issue open.
@OdinVex commented on GitHub (Mar 2, 2024):
I'm unfamiliar with Go, I'm more of an Assembly/C/C++ kind of guy.
Edit: I took a peek around, I think maybe something in
templates/user/dashboard/feeds.tmplcould address it?{{template "base/paginate" .}}That period, does that help to generate a link?@wxiaoguang commented on GitHub (Mar 2, 2024):
Nope. The
dot syntaxis a Golang template syntax, it means "pass all current data into the sub template"@lunny commented on GitHub (Mar 3, 2024):
resolved by #29534
@OdinVex commented on GitHub (Mar 3, 2024):
It is not resolved by #29534, that was a different issue (original fixer misunderstood this bug because another was found at the same time.)
@OdinVex commented on GitHub (Mar 3, 2024):
Thank you @lunny. :)
@wxiaoguang commented on GitHub (Mar 3, 2024):
Well, TBH I do not think I misunderstand this issue (actually I won't call the "slash" problem is a "bug").
Maybe you misunderstand the problem. I will quote my explanations and summarize them again:
https://host/SUBPATHandhttps://host/SUBPATH/, the document has said so:# Note: no trailing slash after either /git or porthref="/SUBPATH?page=2...should work, it doesn't need an extra slash.https://host/SUBPATH,https://host/SUBPATH/user,https://host/SUBPATH/user/repohttps://host/SUBPATH/,https://host/SUBPATH/user/,https://host/SUBPATH/user/repo/I don't see why you wouldn't follow the document and why you insist to add an extra trailing slash for some links, I don't see such a real use-case for end users either.
If you think the trailing slash is a must, please show some real bad cases for no-trailing-slash. Without a real bad case, I couldn't figure out what you mean.
@OdinVex commented on GitHub (Mar 3, 2024):
The fact Gitea uses a forward-slash to begin with is enough to follow convention. Calling #29534 a fix is a hackjob following non-standard practice to assume a file is a directory to circumvent fixing the issue.
Edit: The root of the problem has nothing to do with the Cookie issue. That is a side-effect. The issue of parsing comes into play, mind. Some people build parsers and to have to create an exception for mis-generated links in pagination on one specific page just lends to the idea it should be polished and fixed, not to mention web server parsing specs.
@wxiaoguang commented on GitHub (Mar 3, 2024):
As I explained before, Gitea requires to make "/SUBPATH" the same as "/SUBPATH/". Since it is a "proxy path", it is not related to file or directory. There is no file nor directory in this case.
@OdinVex commented on GitHub (Mar 3, 2024):
Maybe not on your instance or Gitea's official instances. I happen to have a binary file named the same. Access to the instance can only be achieved with that slash, as intended by specs, not just my own. Edit: And yes,
/SUBPATH/is a directory, even if virtual. You might be thinking a piece of path rather than directory as in "folder", the term is interchangeable, but it is indeed intended for the server to provide a default ("app") in this case or conventionally index/default.html or return an error, etc.Edit: To summarize, the issue is a lack of slashes. Your PR does not add slashes, it fixes a different issue (awesome). So when the slashes are added to the user dashboard (the only place this problem occurs) then we'll call it fixed, cause that's this Issue.
@wxiaoguang commented on GitHub (Mar 3, 2024):
The document was written there to help users configure their instances correctly. If some users don't follow, then that's another problem.
As I explained above, Gitea never adds extra slash to the full path. So if you think it is a problem, then not only "pagination" is affected, a lot of hard-coded links are also affected, then it is not a simple problem, it is a new proposal to totally refactor the Gitea's link system.
Would you like to edit the title to clarify what you mean? For example:
Always add an extra slash when the AppSubURL is used without other sub paths("pagination" is just a tip of the iceberg)@OdinVex commented on GitHub (Mar 3, 2024):
This has nothing to do with how users configure their servers. That is not the issue. The issue is not the variable, it's the links generated specifically ONLY on the user dashboard. Yes, Gitea DOES add forward-slashes, you can grep the code for it all over. Pagination ONLY on the USER DASHBOARD is affected. ONLY ON THE USER DASHBOARD. On other pages pagination works correctly (AND HAS FORWARD-SLASHES) such as the repo page.
Repo Page:
USER BLEEPING DASHBOARD:
@OdinVex commented on GitHub (Mar 3, 2024):
First and Previous will also be affected, they using {{
.Link}} instead of {{.Link}}/ as seen on other pages such as./user/settings/security/webauthn.tmpl(data-url="{{$.Link}}/webauthn/delete" data-id="{{.ID}}">). :O A FORWARD-SLASH. If you're re-using the pagination template then it's getting incorrect link information (variable assignment/determination/whatever) from the user dashboard I'd guess.@wxiaoguang commented on GitHub (Mar 3, 2024):
I guess I have explained many times ...
Gitea never adds extra slash to a full path:(Update: OK,
https://host/SUBPATH/is quite special in many cases, sometime it has the trailing slash, sometimes it doesn't)There could be more cases that the SUBPATH misses the correct trailing slash .... for example, I just fixed some: #29535
Anyway, if you believe only the "dashboard" page needs to be fixed, it's fine to me. It could be fixed by this:
-> Add an trailing slash to dashboard links #29555
You could apply this patch to your instance to see whether it satisfy your requirement, I will add some tests later.
@OdinVex commented on GitHub (Mar 3, 2024):
Ah, so the issue of understanding was a language one. It does add forward-slashes for any subdirectory but not for root directory (aka subpath), is what you meant. It should, otherwise clients are sending a parameter request to a file (or a cgi script even such as PHP). Separation of routing by paths (not virtual file pathing) is not only best-practices it can be a requirement in some environments due to software collisions. There is no reason to not use a forward-slash except cosmetic when accounting for all that.
I took a quick look in most places, only the user dashboard had the issue without going too deep into things, I also had to disable Notifications because of an Apache bug with reverse-proxies that prevents multiple threads (ends up blocking new threads because of concurrently held threads) so we wouldn't have noticed the Notifications. We also don't use comments on the instance but rather in Matrix, so we wouldn't have noticed it there either, good finding.
I will find the time to test it, thank you.
Yes, the inconsistency could accidentally be parsed and routed as a file on some servers (if they are not canonizing /SUBPATH as /SUBPATH/). That was why I was trying to point out the whole "it could be a file" thing, because it genuinely could. If it always has forward-slashes then we know for certain we want the instance, instead of any file or accidental misrouting because the forward-slash would be.
@wxiaoguang commented on GitHub (Mar 3, 2024):
Oh one more thing, since we have a long discussion for this simple problem, I think maybe we could try to improve the communication in the future.
What I understand:
What you proposed if I understand correctly now:
Fortunately, eventually, we could understand each other better. 🙏 In the future if there would be some real cases for a proposal/bug report, I think I could catch you up more quickly. Thank you again for the constructive discussion.
@wxiaoguang commented on GitHub (Mar 3, 2024):
Do you mean this? #19265 I also participated in it .... 🤣
@OdinVex commented on GitHub (Mar 3, 2024):
Some installations must follow standards which do not call for canonize paths the way you're assuming users should. This assumption should not be made. The code and documentation should not have ever tried to canonize the name, that should be a user preference to control that sort of redirection if they wish. I'd support the suggestion, but a requirement would remove preference and control (and even be impossible in some situations).
I found that information while building a web server back in early 2004 to specifically build a cgi backend specific to an embedded system (an old Surfboard modem), it's been a long time. I'll try to remember the number. It centered around defining URL/URI and what is considered a file versus a directory and the ambiguity leaving it up to servers to define (but since it's an option it should be left to the user if it isn't required by the server and Gitea doesn't functionally need that because links can be written with a slash addressing it). There was something about case-sensitivity being ignored for host and scheme (port, etc) but specifically not for the rest of a URL/URI and an empty URL/URI should be processed as "/" (but that is only for "" requests, eg empty, and /something is not empty). The RFC was from the 1990s but it was still relevant in HTTP1.1 at the time. (Edit: I have not seen anything that updates or changes anything about assuming a path should end in a "/" and not allowing a file to be served for /subpath versus a proxy at /subpath/ because they can be differentiated by the server routing/processing, still is in Apache. I don't use Nginx, if this behavior is no longer the same among web servers then it's either a free-for-all decision or an RFC update, in which case I'd love to know. Still, canonicalizing the names with forward-slash to prevent issues and polishing things would be the best approach I genuinely believe.) Edit: I also remember the RFC mentioning request erroneous implementations of URI parsing resulting in badly formed queries and it gave a rundown of this stuff specifically mentioning interoperability issues because of URI parsing (such as removing /../ and such from URIs but only if they're in the path, etc). I think it also mentioned something about not making assumptions because of client implementations either intending to access a specific URI.
Edit: Although I can't find the original RFC, here's one that specifically mentions the kind of assumption demonstrated by Gitea:
The language here is implying there is a time it can be appropriate and a time it can be inappropriate. Canonizing to assume a forward-slash instead of allowing for a file by the same name as the subpath proxied for an Instance would be an example of an inappropriate use of technique. For anyone not serving a file Gitea's current behavior would be perfectly reasonable but for others it wouldn't be. Adding a forward-slash of course fixes it for all users in the end, that was why I was trying to communicate it. That RFC isn't the one I remember reading but it does talk about that kind of thing. The section following that,
[7.3](https://www.rfc-editor.org/rfc/rfc3986#section-7.3). Back-End Transcodingalso talks about taking special note of filesystem characters (forward-slash among them) but it merely lends to a summary of trying to not make assumptions about filesystems and such. '/subpath' also belongs to '/' whereas '/subpath/' belongs to the sub-router '/subpath', not '/', I can't remember where I read about that though. It was about trying to differentiate routing and how they should be implemented for user understanding.Edit: I recall the RFC talking about fragmenting the URI and essentially trying to establish "this is a child fragment of this parent" and how to determine that, that document seems to also mention it (but that's a 2014 one, the one I read was from 1990s). "The semantics of a fragment identifier are defined by the set of representations that might result from a retrieval action on the primary resource." A lot of semantics. Canonicalization is fine for those that want it, but if someone wants to serve a file by the same name they should be allowed if it doesn't break Gitea. It can go both ways but supporting the forward-slash removes the ambiguity and fixes the issue for everyone involved. Those not using the forward-slash see nothing different and those using it see it working correctly for them. A bit tired, stayed up too late, bed for me. :)
Yep! :D
@OdinVex commented on GitHub (Mar 3, 2024):
Edit: Woke up recalling this might help explain a perfectly plausible situation for needing the differentiation: /gitea.php is a script that handles authentication (users do not see .php, link canonicalization and disabling of .php direct access) and redirects to /gitea/ after logged in (but the redirect specifically is clean so that people can't try to pass parameters to the instance as soon as they login, avoids exploits around links). Other services are maintained and they all need a unified structure for doing this kind of thing across different systems, so while it is specific it also describes a scenario in which ambiguity assumptions can break something. Temporarily we added Redirector (web browser extension) redirects so that anything /subpath? gets redirected to /subpath/? but it's browser-specific until the patch is tested and rolled out. So many interconnected different softwares and backends, x_X.
@OdinVex commented on GitHub (Mar 4, 2024):
Awesome, very well done. :)