Skip to content

Fix file:// URI handling for desktop-opened comics #44

Description

@JoshCLWren

Problem

The macOS/Linux file-association path handling in cdisplayagain.py incorrectly slices file:// arguments:

if raw.startswith("file://"):
    raw = raw[7]

raw[7] returns one character, not the path after the URI prefix. A file opened through an association that supplies a file:// URI can therefore become a one-character path and fail with “File not found”.

Fix

  • Parse file URIs with urllib.parse.urlparse/unquote, including percent-encoded spaces and non-ASCII paths.
  • Preserve normal filesystem paths and command-line paths unchanged.
  • Handle file:///absolute/path, rather than assuming a simple string slice.

Tests

Add tests for:

  • Plain absolute path.
  • file:///tmp/My%20Comic.cbz.
  • A path containing Unicode characters.
  • A non-file URI or malformed URI with an actionable error.

The regression test must fail against the current raw[7] implementation.

Done criteria

  • A CBZ/CBR opened through a desktop association resolves to the complete filesystem path.
  • Existing direct CLI path handling remains unchanged.
  • Lint and the full test suite pass.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions