OPDS: raw server filenames for download#13230
Conversation
|
Regexp borrowed from #13007 (comment). |
|
Fine by me, but the alignment looks a few pixels off on the screenshot? |
|
Nice catch. |
|
Thanks for working on this, it's much appreciated and will cut down on the number of users running into trouble getting Calibre and KOReader to integrate smoothly. |
| function OPDSBrowser:getServerFileName(item_url) | ||
| local headers = self:fetchFeed(item_url, true) | ||
| if headers then | ||
| logger.dbg("OPDSBrowser: server file headers", headers) |
There was a problem hiding this comment.
I was thinking we should add something like this, maybe in socketutil although it's not really about sockets.
local function log_safe_headers(headers)
local sensitive_headers = {
["authorization"] = true,
["cookie"] = true,
["set-cookie"] = true,
["proxy-authorization"] = true
}
local safe_headers = {}
for key, value in pairs(headers) do
if sensitive_headers[key] then
safe_headers[key] = "REDACTED"
else
safe_headers[key] = value
end
end
logger.dbg("OPDSBrowser: server file headers", safe_headers)
end| end | ||
| end | ||
|
|
||
| function socketutil.safe_headers(headers) |
There was a problem hiding this comment.
redact_headers? This makes me think it does a pcall or some such. :-)
| if sensitive_props[key] then | ||
| safe_request[key] = "REDACTED" | ||
| else | ||
| if key == "headers" then |
There was a problem hiding this comment.
I'd write it as elseif/else but this is fine too.

May be useful for calibre and other self-hosted servers.
Closes #13007.
This change is