mirror of
https://github.com/kiwix/libkiwix.git
synced 2026-01-20 04:08:24 -05:00
/ is no longer a reserved char for urlEncode()
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).
This commit is contained in:
@@ -110,8 +110,8 @@ namespace URLEncoding
|
||||
|
||||
const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const char digits[] = "0123456789";
|
||||
const char nonEncodableSymbols[] = ".-_~()*!";
|
||||
const char uriDelimSymbols[] = ":/@?=+&#$;,";
|
||||
const char nonEncodableSymbols[] = ".-_~()*!/";
|
||||
const char uriDelimSymbols[] = ":@?=+&#$;,";
|
||||
|
||||
const char otherSymbols[] = R"(`%^[]{}\|"<>)";
|
||||
|
||||
@@ -135,7 +135,7 @@ TEST(stringTools, urlEncode)
|
||||
EXPECT_EQ(urlEncode(nonEncodableSymbols, true), nonEncodableSymbols);
|
||||
|
||||
EXPECT_EQ(urlEncode(uriDelimSymbols), uriDelimSymbols);
|
||||
EXPECT_EQ(urlEncode(uriDelimSymbols, true), "%3A%2F%40%3F%3D%2B%26%23%24%3B%2C");
|
||||
EXPECT_EQ(urlEncode(uriDelimSymbols, true), "%3A%40%3F%3D%2B%26%23%24%3B%2C");
|
||||
|
||||
EXPECT_EQ(urlEncode(otherSymbols), "%60%25%5E%5B%5D%7B%7D%5C%7C%22%3C%3E");
|
||||
EXPECT_EQ(urlEncode(otherSymbols), urlEncode(otherSymbols, true));
|
||||
|
||||
Reference in New Issue
Block a user