-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Don't manually replace whitespace during render #10291
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
Conversation
For historical reasons Gitea manually alters the urlPrefix and replaces a whitespace with a +. This Works for URLs, but we're also passing urlPrefix to git calls and adding the + is breaking the tree path. Goldmark will automatically convert a white space to the proper %20, so we should leave the string as is which lets us pass it to git unmodified and then let Goldmark fix it. Also fixed separate bug in URLJoin I noticed while testing where it will silently discard sections of a path that have # in them (possibly others). We should just escape it first. Fixes 10156
Hmm will need more though on escaping elems here |
This reverts commit 8bf4959.
@guillep2k had to revert escaping the elements because it breaks valid fragment links like mypage#section1 and would involve more logic rewriting in general. I notice a few other bugs with filenames that have a pound sign/how we handle what we think are anchors in markdown and I think all of that logic needs to be looked into in a separate PR. This PR will still fix issues mentioned above with regards to folder names and filenames with white spaces with just a few lines. |
Fair enough. Please send an empty commit to restart CI. |
I've been reading the code, and now I'm not so sure about |
You're right, anything that needs to should be escaped before being passed to that function or needs more thought anyways. I've just remove that change from this PR as it should be part of another refactor that addresses #10300 better (which is how I came across it). Updated PR description as well. |
Codecov Report
@@ Coverage Diff @@
## master #10291 +/- ##
==========================================
+ Coverage 43.68% 43.69% +0.01%
==========================================
Files 585 585
Lines 81010 81015 +5
==========================================
+ Hits 35390 35402 +12
+ Misses 41238 41226 -12
- Partials 4382 4387 +5
Continue to review full report at Codecov.
|
* Don't manually replace whitespace during render For historical reasons Gitea manually alters the urlPrefix and replaces a whitespace with a +. This Works for URLs, but we're also passing urlPrefix to git calls and adding the + is breaking the tree path. Goldmark will automatically convert a white space to the proper %20, so we should leave the string as is which lets us pass it to git unmodified and then let Goldmark fix it. Also fixed separate bug in URLJoin I noticed while testing where it will silently discard sections of a path that have # in them (possibly others). We should just escape it first. Fixes 10156 * Escape elems as well * Revert "Escape elems as well" This reverts commit 8bf4959. * restart ci * remove changes to URLJoin * restart ci Co-authored-by: techknowlogick <matti@mdranta.net>
* Don't manually replace whitespace during render For historical reasons Gitea manually alters the urlPrefix and replaces a whitespace with a +. This Works for URLs, but we're also passing urlPrefix to git calls and adding the + is breaking the tree path. Goldmark will automatically convert a white space to the proper %20, so we should leave the string as is which lets us pass it to git unmodified and then let Goldmark fix it. Also fixed separate bug in URLJoin I noticed while testing where it will silently discard sections of a path that have # in them (possibly others). We should just escape it first. Fixes 10156 * Escape elems as well * Revert "Escape elems as well" This reverts commit 8bf4959. * restart ci * remove changes to URLJoin * restart ci Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: techknowlogick <matti@mdranta.net>
For historical reasons Gitea manually alters the urlPrefix and replaces a whitespace with a
+
. This Works for URLs, but we're also passing urlPrefix to git calls and adding the+
is breaking the tree path.Goldmark will automatically convert a white space to the proper
%20
, so we should leave the string as is which lets us pass it to git unmodified and then let Goldmark fix any whitespaces when rendering. This keeps treePath and the generated link working. See #10156 for more details.Fixes #10156
Here is example of broken + behavior that is fixed:
https://try.gitea.io/mrsdizzie/testcase/src/branch/master/test%20a