-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Check for either escaped or unescaped wiki filenames #8408
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm puzzled. In Theory this should break made-up cases where both
c%C3%A1mara
andcámara
exist, but I couldn't make it fail.To handle this properly we should probably use only
unescapedTarget
(like in your previous PR) and add a migration step. However I don't think a migration is a very good idea because many things can go wrong for such an edge case.All in all, If possible, I'd change this to check if there are any entries that matches
target
. Only if there is none then I'd resort to the one matchingunescapedTarget
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, I'm very much still learning Go, but if I understand correctly, a case where both
c%C3%A1mara
andcámara
exists wouldn't fail because the logic stops executing after it gets atrue
for the comparison againsttarget
. The check againstunescapedTarget
would never even happen in that case. So it should already be performing the way you describe. I think...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a for loop in a range (array), it will sequencially check values like:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I follow your example... Wouldn't it be more like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the original (imported) wiki has two pages
cámara
andc%C3%A1mara
, what are the URLs for those? According to online encoders those are:But then you have:
As you can see,
unescaped2
==page1
. So they look the same and you have a name collision.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Now I know why I couldn't reproduce the problem: I had to import a wiki, not edit the wiki from Gitea's editor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in that case, one of those pages would be inaccessible depending on which one comes up last in the for loop. But no matter how you write your logic, I'm pretty sure that would always be the case as long as you're effectively checking against two possible filenames. I suppose I would just assume that users aren't saving their wiki pages with machine-readable sequences of characters. Sure, doing so would cause another bug. But it seems to me like that's a lot less likely to ever be an issue than the current bug.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a logic like this, you leave the window open for the user to fix things in case of name collision (e.g. renaming the file or changing the links).
It's actually pretty easy:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the error from
QueryUnescape()
should not be ignored.