Skip to content

OPDS: raw server filenames for download#13230

Merged
hius07 merged 9 commits into
koreader:masterfrom
hius07:opds-filename
Feb 11, 2025
Merged

OPDS: raw server filenames for download#13230
hius07 merged 9 commits into
koreader:masterfrom
hius07:opds-filename

Conversation

@hius07

@hius07 hius07 commented Feb 10, 2025

Copy link
Copy Markdown
Member

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

1

2


This change is Reviewable

@hius07

hius07 commented Feb 10, 2025

Copy link
Copy Markdown
Member Author

Regexp borrowed from #13007 (comment).

@Frenzie

Frenzie commented Feb 10, 2025

Copy link
Copy Markdown
Member

Fine by me, but the alignment looks a few pixels off on the screenshot?

@hius07

hius07 commented Feb 10, 2025

Copy link
Copy Markdown
Member Author

Nice catch.
"Show password" is built-in into InputText widget, new checkbox is added to MutiInputDialog via AddWidget(). I'll look into it.

@hius07

hius07 commented Feb 10, 2025

Copy link
Copy Markdown
Member Author

3

@darrenoc3

Copy link
Copy Markdown

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.

@Frenzie Frenzie added this to the 2025.02 milestone Feb 10, 2025
Comment thread plugins/opds.koplugin/opdsbrowser.lua Outdated
function OPDSBrowser:getServerFileName(item_url)
local headers = self:fetchFeed(item_url, true)
if headers then
logger.dbg("OPDSBrowser: server file headers", headers)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread frontend/socketutil.lua Outdated
end
end

function socketutil.safe_headers(headers)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redact_headers? This makes me think it does a pcall or some such. :-)

Comment thread frontend/socketutil.lua
Comment thread frontend/socketutil.lua Outdated
if sensitive_props[key] then
safe_request[key] = "REDACTED"
else
if key == "headers" then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd write it as elseif/else but this is fine too.

@hius07 hius07 merged commit 41dd3d5 into koreader:master Feb 11, 2025
@hius07 hius07 deleted the opds-filename branch February 11, 2025 12:13
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

how to export a ebook through opds calibre with actual filename

3 participants