Skip to content

docs: "always decodeURIComponent(currentFilename)" pitfall doesn't account for filenames containing a literal % #35

Description

@carochacs

CLAUDE.md's Common Pitfalls section says:

currentFilename may be percent-encoded — always decodeURIComponent(currentFilename) before building URLs in pane plugins.

"May be" + "always decode" is a lossy pair. If currentFilename is sometimes not encoded, and a real filename legitimately contains a % (e.g. 100% Live.sloppak), an unconditional decodeURIComponent call either throws a URIError (malformed sequence) or silently corrupts the name (a %XX that happens to look like valid encoding). The doc doesn't establish the invariant it's assuming ("currentFilename is always exactly-once encoded when this rule applies").

Suggest one of:

  • Establish and document the actual invariant at the source (playSong always receives an encoded name / always receives raw — pick one and enforce it), or
  • Decode defensively: try { decodeURIComponent(x) } catch { x }, or detect whether the string is already encoded before decoding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions