mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
Markdown links started with / broken in 1.23 #13991
Closed
opened 2025-11-02 10:59:25 -06:00 by GiteaMirror
·
14 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.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.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-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
No Label
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#13991
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 @didim99 on GitHub (Jan 14, 2025).
Description
If you paste a link tag in any place (MD files, issues, comments) started with leading
/(without domain) it don't works anymore in 1.23. I'm not sure about 1.22.5 or 1.22.6 but for 1.22.4 or older version this kind of links works perfectly: parsed as absolute URL for whole Gitea instance (domain). For now these liks are parsed as relative to current repository.For example, if you want to link other repo now you need to specify full URL, including domain and port (if customized). In case of transfer Gitea instance to another domain/port it seems to be better to use absolute URLs without domain.
This change broken all our documentation system and old conversation in issues, please, fix it!
Gitea Version
1.23.1
Can you reproduce the bug on the Gitea demo site?
Yes
MD: https://demo.gitea.com/didim99/test-2/src/branch/master/readme.md
Issues: https://demo.gitea.com/didim99/test/issues/1#issue-798
Log Gist
No response
Screenshots
No response
Git Version
Not matters
Operating System
Not matters
How are you running Gitea?
Official install script (updated from 1.22.6)
Database
MySQL/MariaDB
@TheFox0x7 commented on GitHub (Jan 14, 2025):
@wxiaoguang FYI since you refactored that part.
I think current behavior is more correct and mirroring github one. Though it wasn't marked as a breaking change.
@didim99 commented on GitHub (Jan 14, 2025):
@TheFox0x7 I read this github blog post and related documentation page and can't find any information about links with leading
/character. Nothing like "absolute links starting with/should not work". And in HTML standard that kind of URLs is correct.Okay, relative links without leading
/works as before (including ones that contains..sequence), sounds really like "mirroring github", but there is nothing about leading/. It worked before for a years (at least since mid 2022) and don't works now. So I think it's a bug.@TheFox0x7 commented on GitHub (Jan 14, 2025):
Fair enough, I missed that there's no
/in front in that github document. My apologies.I'm not saying it's not a bug, it is a breaking change which went unannounced so it might as well be a bug/regression.
I did test relative links on github and it treats relative and absolute paths the same, see: https://github.com/TheFox0x7/repro/blob/main/linker.md
What I gather is that you want the
/*links to not include the base repository like in the test here:https://github.com/go-gitea/gitea/blob/main/modules/markup/render_link_test.go#L21
/abeing base repository,bbeing current path in the repository (I'm guessing), and/cbeing the link from the markup content, which should resolve to/cinstead of/a/c. Correct?I think changing this line to be just link would cover that, though then the nested absolute path test fails and I'm not sure whats the purpose of the
/owner/..../owner/..case.@wxiaoguang commented on GitHub (Jan 15, 2025):
Yup, it's not broken but just follows other git service's behavior like GitHub.
If you'd like to cross-reference the documents, it needs to use use full link (with
https://host/prefix)Sorry for the "breaking" change, because there are more stronger requirements for it:
ps: I see you are using "readme" for an org, actually there is a feature "profile readme", you could put the readme in
{org}/.profile/README.md, then it will be rendered at the org's home page.@didim99 commented on GitHub (Jan 15, 2025):
@TheFox0x7 yep, and tests that you mentioned above written in opposite approach.
@wxiaoguang yes, that's true. But "as others" not always means "better", right? Previous approach was more flexible, allows choice between absolute and relative links using leading /, and for now no more choice.
My proposal is: if this is not too hard to implement, could you make this behaviour configurable via app.ini? Something like
ui.use_absolute_linkswith defaultfalse(github-like) but with ability to settingtruefor backward compatibility for those who used this feature before.Readme is just an example. Actually all our cross-repo links (hundreds of them) such as code reference in issues, documentation and so on were written in that manner for portability reason (changing base domain (especially port number) of gitea instance do not broke these links).
@silverwind commented on GitHub (Jan 15, 2025):
This
/org/repo/file.mdis ambigous with in-repo file links like/file.mdwhich work in both GitHub and Gitea. To really distinguish the two, an new non-ambiguous syntax would be needed, maybe prefix with//or something similar like protocol-relative URLs, but not exactly the same either.@wxiaoguang commented on GitHub (Jan 15, 2025):
I do not think
//could work here, it only omits the "protocol" part.@silverwind commented on GitHub (Jan 15, 2025):
Yea we'd need a "origin-relative" or "suburl-relative" URL, but there is no standard for that as far as I'm aware. Maybe
///😆@wxiaoguang commented on GitHub (Apr 3, 2025):
Or maybe
/./path-to-site-root? It won't break existing URLs and is a pretty valid URL@didim99 what do you think?
@didim99 commented on GitHub (Apr 3, 2025):
@wxiaoguang I'm agree, it may be a solution in terms of most possible compatibility.
@wxiaoguang commented on GitHub (Apr 3, 2025):
I am going to make some more improvements to the markdown module (to clean up some legacy problems). For this "relative link" problem, there are some initial ideas in my mind at the moment, let's see how good we can make it:
use_absolute_links=true/./path-to-site-root/@root/path-to-site-root, for example:/@root/AnotherOrg/TheRepo/issues/@owner/a-repo-name, for example:/@owner/AnotherRepo/issues/@repo/a-path-in-repo, for example:/@repo/src/branch/raw/...The special names seem flexible enough, the only question is that whether it would cause unsolvable conflict in the future.
@mentioning parser?/$root/....?@silverwind commented on GitHub (Apr 3, 2025):
We should only definitely use characters that are forbidden in repo and org names. I think
@is forbidden in both, but good to double-check as I recall gitea is still allowing too much and is not compatible with github regarding allowed repo and org names (see https://github.com/go-gitea/gitea/issues/4150#issuecomment-2142191169 and https://github.com/go-gitea/gitea/issues/4150#issuecomment-2142204117 specifically).@didim99 commented on GitHub (Apr 3, 2025):
@wxiaoguang using special names looks very nice! IMO using
@as marker char is a not best idea because that notation used for mentions,$(or maybe something else, but for now I not have any suitable proposal) is more preferred in this case.@wxiaoguang commented on GitHub (Apr 4, 2025):
-> Refactor markup render to fix various path problems #34114
The final decision in my mind is "using
:"The reason is:
:is a valid URL path character, no need to escape:won't conflict with other designs (@for mentioning,$for variable, etc)