-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Quick-fix of issues caused by URL encoding #870
Conversation
Codecov ReportBase: 71.45% // Head: 72.01% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #870 +/- ##
==========================================
+ Coverage 71.45% 72.01% +0.55%
==========================================
Files 53 53
Lines 3749 3745 -4
Branches 2096 2093 -3
==========================================
+ Hits 2679 2697 +18
+ Misses 1068 1046 -22
Partials 2 2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@mgautierfr Please assess if the quick-fix has any undesirable side-effects. I can think of only subtle ones due to broken interplay between ZIM creation software that might put |
If I resume the change:
So with this change and encoded reserved to true, what changes is that we don't encode (Please confirm I right)
|
As you know, any value but |
@mgautierfr Thanks for the meticulous analysis!
Confirming
This one is a bug. URI delimiters occurring in the path must be encoded! Fixed.
Good catch. While working on the robust solution, I changed Fixed. Category name is now fully URI-encoded.
Dropped this one. |
Done |
Also fixed usage of |
We should not. The search result link is in the form :
Yes. And we could call it
This way we preserve |
But that's what is changed by this PR! |
🤦🏽♂️ My bad. I've mixed too much things. So I think we are good. We just have to remove the Just want to mention for potential issue later: We are ok to not encode |
Added a unit-test for urlEncode() that passes for its current implementation despite the two bugs that were revealed while creating the unit-test.
Replaced tabs with spaces.
This change is a quick hack solving known issues with URI-encoding in libkiwix. This change removes the slash character from the list of URL separator symbols in URL encoding/decoding utilities, and makes it a symbol that is safe to leave unencoded. Effects: - `urlEncode()` never encodes the '/' symbol (even when it is requested to encode the URL separator symbols too). - `urlDecode(str)`/`urlDecode(..., false)` will now decode %2F to '/'; other encoded URL separator symbols are NOT decoded when the second argument of `urlDecode()` is set to false (which is the default).
Special URI symbols occurring in the item path part of the search result link were NOT encoded, because that would also encode the path separator (/) symbol. Now that `urlEncode()` never encodes the / symbol, it is safe to encode all other URI-special symbols in the path.
This is a precautionary step before dropping the said parameter.
`urlEncode(str)` is now equivalent to the previous `urlEncode(str, true)`.
125a576
to
ca079a7
Compare
Done (also rebased).
I stumbled upon "thank" in this sentence, but then figured out that you meant "thought" :) |
Fixes kiwix/kiwix-tools#594 (hopefully, without introducing another bug).
I started working on a more robust solution to #775 on branch robust_uri_encoding but then started having a feeling of overdesigning and overcomplicating things. So I tried a quick hack (see the last commit in this PR) and it seemed to work, so I decided to package the new unit-tests, fixes to a couple of bugs revealed by those tests and the hack into a PR of its own.