Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression - 1.22 wiki links which contain dots point to "raw" media and only return plain text #31395

Closed
reimer-atb opened this issue Jun 17, 2024 · 4 comments · Fixed by #31398 or #31825
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented issue/regression Issue needs no code to be fixed, only a description on how to fix it yourself type/bug
Milestone

Comments

@reimer-atb
Copy link

Description

Steps to reproduce

  1. Create a wiki page with a hyphen - or a dot . in the name
  2. Link to that page from another wiki page

Result

Clicking on the link will only return a plain text representation of the linked wiki page's content.

Expected Result

The whole wiki page html should be returned

Additional info

This was working in gitea 1.21.8.

The auto-generated URLs for the wiki pages with a hyphen end in .- and the ones for wiki pages with a . contain the dot.

I assume that this change caused the problem.

Example project with wiki

https://demo.gitea.com/reimer-atb/test/wiki/Home

Example markdown with links that do not work

Welcome to the Wiki.

- [Test](Test) => works
- [Test with spaces](Test-with-spaces) => works
- [Test-with-hyphen](Test-with-hyphen.-) => does **not** work
- [Test+with+spaces+2024-06-17.-](Test+with+spaces+2024-06-17.-) => does **not** work
- [2024-06-17](2024-06-17.-) => does **not** work
- [17-06-2024](17-06-2024.-) => does **not** work
- [17.06.2024](17.06.2024) => does **not** work
- [06/17/2024](06%2F17%2F2024) => works
- [17/06/2024](17%2F06%2F2024) => works

Gitea Version

1.22.0

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Tested on demo.gitea.com and on a private gitea 1.22.0 instance (no idea how that is run because it is provided by someone else).

Database

None

@wxiaoguang
Copy link
Contributor

-> Fix rendered wiki page link #31398

wxiaoguang added a commit that referenced this issue Jun 18, 2024
wxiaoguang added a commit to wxiaoguang/gitea that referenced this issue Jun 18, 2024
Fix go-gitea#31395
# Conflicts:
#	modules/markup/markdown/transform_link.go
#	routers/web/repo/view.go
wxiaoguang added a commit that referenced this issue Jun 19, 2024
@reimer-atb
Copy link
Author

@wxiaoguang please re-open because this is not fixed completely yet. Links are still broken if a wiki page's title contains a dot ..

Example pages:

  • "Meeting 18.07.2024"
  • "main.go"

See https://demo.gitea.com/reimer-atb/test/wiki/Home

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jul 18, 2024

There is still a regression, from "Use raw Wiki links for non-renderable Wiki files (#30273)"

30273 renders all links to raw by default.

ps: I don't have time to work on Gitea at the moment. So if anyone has interest, feel free to fix or revert.

@wxiaoguang wxiaoguang reopened this Jul 18, 2024
@wxiaoguang wxiaoguang changed the title Regression - after update to 1.22 wiki links to wiki pages with hyphens or dots in the name only return plain text Regression - 1.22 wiki links which contain dots point to "raw" media and only return plain text Jul 19, 2024
@wxiaoguang wxiaoguang added issue/regression Issue needs no code to be fixed, only a description on how to fix it yourself issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented labels Jul 24, 2024
@wxiaoguang wxiaoguang added this to the 1.22.2 milestone Jul 24, 2024
@Zettat123
Copy link
Contributor

I did some tests on GitHub.

The link in Home.md is

- [main.go](main.go)
  • If main.go.md and main.go both exist, the content of main.go.md will be rendered when clicking the link
  • Only main.go.md exists but no main.go, the same as above
  • Only main.go exists but no main.go.md, the plain text of main.go will be displayed
  • If neither main.go.md nor main.go exist, the page for creating a new wiki will be displayed

I think we can fix the issue like GitHub does. We can check if the corresponding .md file exists when rendering the link.
If the .md file does not exist, render the raw file link.

GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Aug 16, 2024
Fix go-gitea#31395

This regression is introduced by go-gitea#30273. To find out how GitHub handles
this case, I did [some
tests](go-gitea#31395 (comment)).

I use redirect in this PR instead of checking if the corresponding `.md`
file exists when rendering the link because GitHub also uses redirect.
With this PR, there is no need to resolve the raw wiki link when
rendering a wiki page. If a wiki link points to a raw file, access will
be redirected to the raw link.
lunny added a commit that referenced this issue Aug 17, 2024
Backport #31825 by @Zettat123

Fix #31395

This regression is introduced by #30273. To find out how GitHub handles
this case, I did [some
tests](#31395 (comment)).

I use redirect in this PR instead of checking if the corresponding `.md`
file exists when rendering the link because GitHub also uses redirect.
With this PR, there is no need to resolve the raw wiki link when
rendering a wiki page. If a wiki link points to a raw file, access will
be redirected to the raw link.

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented issue/regression Issue needs no code to be fixed, only a description on how to fix it yourself type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants