mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-18 22:22:24 -05:00
Dashes in Wiki page titles are replaced with spaces #3647
Closed
opened 2025-11-02 05:20:28 -06:00 by GiteaMirror
·
17 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
v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.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
No Label
type/proposal
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#3647
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 @qwertfisch on GitHub (Jul 22, 2019).
Description
The Gitea internal wiki does not allow dash characters in page titles. I can enter it on creation, but it is replaced with a space on display.
I know that the direct cause is that spaces are replaced with dashes on filename level (also in the URL), so there is no distinction between spaces and dashes when reopening a page. Hence it will all be escaped and displayed as a space character.
Attempted workaround with URL-escaped character
All non-ASCII Unicode characters are displayed as URL-escaped variants of their Unicode code point, and even
/is replaced with%2F. So I would expect that a filename containing%2D(stands for the dash) could be loaded and displayed with its correct title. I had manually created such a file, pushed it, but the %2D-escaped dash is still further escaped to a space. Even worse: the URL with the page won’t load anymore.This looks like a deeper error in escape handling with the dash character.
@zeripath commented on GitHub (Jul 22, 2019):
If what I suspect is happening is, then I bet if you use %252D it will work.
However that's not really a solution...
@lunny commented on GitHub (Jul 23, 2019):
It seems we already have a PR to fix this.
@qwertfisch commented on GitHub (Jul 24, 2019):
@lunny In the list of open PRs I could not find anything related. Can you reference the PR in mind?
@qwertfisch commented on GitHub (Jul 24, 2019):
@zeripath Sorry, that does not work either. The replacement of a dash character to a space seems to be executed right after URI decoding, but there is no double decoding.
I made an overview table to see the different behaviour. The last column means that a page can be loaded on the given URL, which does not work in the second and third case. It is only visible in the list of all pages.
colon%3A-try-it.mdcolon%3A-try-itspace%20test.mdspace-testpage-with-one%2Ddash.mdpage-with-one-dashpage-with-one%252Ddash.mdpage-with-one%2DdashThe second and third rows are kind of confusing. It looks as if %20 and %2D are URI decoded from the filename, then there is the default dash/space conversion to create a page title. But when creating the URL, it seems as if it’s not created from filename, but from the (previously decoded) page title. Which of course results in
-characters for all spaces (and no dash at all), so neither the correct file with%2Dnor%20can be found.Suggestion
Can’t we just remove skip the errornous space/dash conversion and store the page with URI encoding? This would solve every problem case, with the slight disadvantage of spaces encoded
%20in the URL …@mrsdizzie commented on GitHub (Jul 24, 2019):
Haven't looked too close but this is probably happening here:
d4667a4949/models/wiki.go (L43-L53)So its first unescaping the file name and then running it through something that just replaces - with " " which matches described behavior.
I agree the filenames should have always been stored encoded but unfortunately they weren't and changing that would put dashes in the title of everyones page where they weren't there before. Would be a breaking change to consider.
@zeripath commented on GitHub (Jul 24, 2019):
Make it a per repo configurable?
@mrsdizzie commented on GitHub (Jul 24, 2019):
I hesitate to add yet more config options, particularly to keep a behavior that is not good (current replacing of space with dash).
I'd rather try and have some sort of code to handle legacy cases, or even just consider all literal dashes as spaces (breaking the less common case of a dash in the title) and then escape everything going forward and handle that properly.
I guess that would maybe look like first replacing all literal dashes and then escaping the filename. It would only break existing titles with a dash in them which already seem to not work properly anyways per this issue
@zeripath commented on GitHub (Jul 24, 2019):
Hmm what happens to + ?
@mrsdizzie commented on GitHub (Jul 24, 2019):
In what situation? I think in the situation of saving a new filename we should make sure to encode + to %2B and not leave it as +
Are you asking if somebody already has a + in their filename? If so that should just still work since any unencoding wouldn't mess with it.
@mrsdizzie commented on GitHub (Jul 24, 2019):
Probably the real problem to solve would be preserving current links or making sure they still work somehow
@qwertfisch commented on GitHub (Jul 25, 2019):
@zeripath
+and?are escaped and can be used properly. In fact every ASCII special character is usable. Only-._~are not encoded but put directly in the filename / URL. (And of course the space is converted to dash before storing as file. This should be%20normally.)chartest-%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F%3A%3B%3C%3D%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D~%C2%A7.md@zeripath commented on GitHub (Jul 25, 2019):
@mrsdizzie @qwertfisch I was meaning that a plain '+' in an url should map to ' ' by convention, and through my testing it appears that this doesn't get mapped to '-' but rather retains the ' ' when passed through - so you should be able to reach a file with spaces in that way.
Yeesh this is so broken. I've been ignoring the wiki, as like the diff page, as I have been suspicious that it needs a thorough overhaul. This proves my fears.
@mrsdizzie I agree that adding configuration should be avoided as much as is possible. If we don't want to add configuration another option is to from 1.10 do things correctly but fallback to the previous behaviour if the old way would have a different file?
@mrsdizzie commented on GitHub (Jul 26, 2019):
Perhaps -- probably something to think about if redesigning this. I'll note that it appears Gitea has just copied this same exact behavior from Github, which does the same thing with dashes and titles/filenames and you can't create a page title with dashes in the title there either.
@icetiger1974 commented on GitHub (May 19, 2021):
hello
Is this issue solved?
Or remain in the same situation?
@unchaynd commented on GitHub (Dec 17, 2022):
You can't put a dash in a Wiki page title?... Seriously??
@zeripath commented on GitHub (Dec 18, 2022):
See https://github.com/go-gitea/gitea/issues/7570#issuecomment-515313767
Can you put a dash in a wiki page title on Github or Gitlab? If you can we should make that work - but otherwise we won't be compatible with gh.
@rrrutledge commented on GitHub (Jan 12, 2023):
😢