From 7fd9de65e4acfdbb71b284353043c19e2f152acd Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 19 Feb 2022 11:55:06 +0100 Subject: Fix not being able to load local files with ?, #, etc --- src/utils/twtstr.nim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/utils') diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 6f324f49..df8cfa6e 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -411,6 +411,11 @@ const PathPercentEncodeSet* = (QueryPercentEncodeSet + {'?', '`', '{', '}'}) const UserInfoPercentEncodeSet* = (PathPercentEncodeSet + {'/', ':', ';', '=', '@', '['..'^', '|'}) const ComponentPercentEncodeSet* = (UserInfoPercentEncodeSet + {'$'..'&', '+', ','}) const ApplicationXWWWFormUrlEncodedSet* = (ComponentPercentEncodeSet + {'!', '\''..')', '~'}) +# used by client +when defined(windows) or defined(OS2) or defined(DOS): + const LocalPathPercentEncodeSet* = (QueryPercentEncodeSet + {'?', ':'}) +else: + const LocalPathPercentEncodeSet* = (QueryPercentEncodeSet + {'?', ':', '\\'}) proc percentEncode*(append: var string, c: char, set: set[char], spaceAsPlus = false) {.inline.} = if spaceAsPlus and c == ' ': @@ -428,6 +433,9 @@ proc percentEncode*(append: var string, s: string, set: set[char], spaceAsPlus = func percentEncode*(c: char, set: set[char]): string {.inline.} = result.percentEncode(c, set) +func percentEncode*(s: string, set: set[char]): string = + result.percentEncode(s, set) + func percentDecode*(input: string): string = var i = 0 while i < input.len: -- cgit