Device
Some Kobo, irrelevant
KOReader version
idk, but the problem is in the main branch
Model and firmware version
No response
Issue description
The urlencode function does not encode the characters (,),' and thus (at least with my Android WebDav server) the download fails and a zero bytes file is created.
This implementation would be RFC 3896 compliant:
function WebDavApi.urlEncode(str)
if not str then return nil end
-- RFC 3986 defines "unreserved" characters:
-- ALPHA (A-Z, a-z), DIGIT (0-9), '-', '.', '_', '~'
-- The pattern below matches any character that is NOT an unreserved character.
-- %w includes ALPHA and DIGIT.
-- The set [^%w%.%-%_%~] matches characters NOT in the unreserved set.
return string.gsub(str, "([^%w%.%-%_%~])", function(c)
-- Get the byte value of the matched character
local byte_val = string.byte(c)
-- Special handling for SPACE (32) and other common reserved characters
-- For full compliance, any character not in the "unreserved" set is encoded.
-- We encode the byte value as a two-digit hex string prefixed with %.
return string.format("%%%02X", byte_val)
end)
end
I can submit a PR if of interest
Device
Some Kobo, irrelevant
KOReader version
idk, but the problem is in the main branch
Model and firmware version
No response
Issue description
The urlencode function does not encode the characters (,),' and thus (at least with my Android WebDav server) the download fails and a zero bytes file is created.
This implementation would be RFC 3896 compliant:
I can submit a PR if of interest