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

Unescape wiki filename string #8374

Closed
wants to merge 3 commits into from
Closed

Unescape wiki filename string #8374

wants to merge 3 commits into from

Conversation

Tekaoh
Copy link
Contributor

@Tekaoh Tekaoh commented Oct 3, 2019

This pull request allows wiki pages with special characters in the title to be accessed.

Fixes #8284

@Tekaoh
Copy link
Contributor Author

Tekaoh commented Oct 3, 2019

Hmm... This builds on my machine. I'll have to figure out what I did wrong to make the test build fail... Sorry about that

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 3, 2019
@Tekaoh Tekaoh changed the title Unescape wiki filename string Fixes go-gitea/gitea#8284 Unescape wiki filename string Oct 3, 2019
@Tekaoh Tekaoh changed the title Unescape wiki filename string Unescape wiki filename string Fixes #8284 Oct 3, 2019
@Tekaoh Tekaoh changed the title Unescape wiki filename string Fixes #8284 Unescape wiki filename string (Fixes #8284) Oct 3, 2019
@Tekaoh
Copy link
Contributor Author

Tekaoh commented Oct 3, 2019

Well, now I'm not too sure what... Maybe someone has a suggestion

@guillep2k
Copy link
Member

It's failing the unit test TestEditWikiPost():

image

Are you able to run that test it in your computer?

@guillep2k
Copy link
Member

You can test it yourself using:

cd routers/repo
go test -tags="sqlite sqlite_unlock_notify" -run TestEditWikiPost

Or even better:

TAGS="sqlite sqlite_unlock_notify" make clean generate test

(that would run all unit tests, but not the integration tests).

When WikiNameToFilename() passes the name through url.QueseryEscape(), it no longer matches the filename
in cases where there are special characters in the name. Adding url.QueryUnescape() restores any
special characters in the filename so that these pages can be found.
@Tekaoh
Copy link
Contributor Author

Tekaoh commented Oct 4, 2019

@guillep2k Thanks for the tip!

I think I've worked out a better solution. Basically the issue is that when WikiNameToFilename() passes the name through url.QueryEscape(), it actually no longer matches the filename in cases where there are special characters in the name. But the unit test has a fit when it's not there. So I added url.QueryUnescape() to wikiContentsByName() to correct any special characters later so that these pages can be accessed.

@codecov-io
Copy link

codecov-io commented Oct 4, 2019

Codecov Report

Merging #8374 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8374      +/-   ##
==========================================
- Coverage    41.8%   41.79%   -0.01%     
==========================================
  Files         496      496              
  Lines       65586    65586              
==========================================
- Hits        27418    27412       -6     
- Misses      34655    34659       +4     
- Partials     3513     3515       +2
Impacted Files Coverage Δ
routers/repo/wiki.go 40.88% <100%> (ø) ⬆️
modules/process/manager.go 76.81% <0%> (-4.35%) ⬇️
models/gpg_key.go 55.83% <0%> (-0.84%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb7c23f...ccd0ea8. Read the comment docs.

@guillep2k
Copy link
Member

No worries.
Now your PR passes the tests, but the CI got stuck on 'notify'. Somebody will look into that.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 5, 2019
@lafriks lafriks added this to the 1.10.0 milestone Oct 5, 2019
@lunny
Copy link
Member

lunny commented Oct 6, 2019

@Tekaoh could you add a unit test?

@Tekaoh
Copy link
Contributor Author

Tekaoh commented Oct 6, 2019

@lunny I wouldn't know how, or even really what that means lol... I just took a try at fixing the bug I found. My commit fixes it, but I'm not entirely sure about all the correct procedures...

@lunny
Copy link
Member

lunny commented Oct 6, 2019

@Tekaoh You can find many example on https://github.com/go-gitea/gitea/blob/master/models/wiki_test.go#L33 and I think it's not complicated.

@Tekaoh
Copy link
Contributor Author

Tekaoh commented Oct 6, 2019

I did some deeper digging and found that this PR is not going to be a good solution. I am therefore going to just close it for now and have another pass at it.

Please see my explanation at #8284 (comment)

@Tekaoh Tekaoh closed this Oct 6, 2019
@Tekaoh Tekaoh changed the title Unescape wiki filename string (Fixes #8284) Unescape wiki filename string Oct 6, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wiki pages with special characters in mirrors are broken
7 participants