Fix core path/sanitization bugs #7

Open
r2d2-bot wants to merge 3 commits from 1-fix-path-sanitization-bugs into master
Collaborator

Closes #1

Fixes the three root-cause bugs behind broken .m3u playlists:

  1. m3uWriter.ts now uses m3u.extendedWriter() so output starts with #EXTM3U.
  2. getLocalPath() is rewritten to be robust to a trailing slash on REMOTE_ROOT_PATH and to backslash-separated server paths, and always returns a path starting with /.
  3. Adds sanitizePathSegment() (not yet wired into downloads on-disk naming; that stays raw per MASTER_PLAN, and is available for the future sync command).

Also adds a typecheck script (tsc --noEmit) and a minimal ambient declaration for the untyped m3u package so strict-mode typecheck passes.

Verified m3u.extendedWriter() is the correct export name in the installed m3u@0.0.2 package (node_modules/m3u/lib/m3u.js).

Closes #1 Fixes the three root-cause bugs behind broken .m3u playlists: 1. m3uWriter.ts now uses m3u.extendedWriter() so output starts with #EXTM3U. 2. getLocalPath() is rewritten to be robust to a trailing slash on REMOTE_ROOT_PATH and to backslash-separated server paths, and always returns a path starting with /. 3. Adds sanitizePathSegment() (not yet wired into downloads on-disk naming; that stays raw per MASTER_PLAN, and is available for the future sync command). Also adds a typecheck script (tsc --noEmit) and a minimal ambient declaration for the untyped m3u package so strict-mode typecheck passes. Verified m3u.extendedWriter() is the correct export name in the installed m3u@0.0.2 package (node_modules/m3u/lib/m3u.js).
- getLocalPath() now normalizes both REMOTE_ROOT_PATH and server paths
  to forward slashes before slicing, handles a trailing slash on
  REMOTE_ROOT_PATH, and always returns a path starting with '/'.
- Add sanitizePathSegment() to strip filesystem-illegal characters and
  trailing dot/space (Unicode names, e.g. Japanese titles, pass through
  unchanged). Not yet wired into download's file naming (out of scope,
  see PLANNING/STEP_1_PLAN.md).
- m3uWriter.ts now uses m3u.extendedWriter() so output starts with
  #EXTM3U, and builds relative paths without assuming a leading slash,
  fixing dot-fused filenames like .Artist/Album/Song.mp3.
- Remove unused writeFile import in m3uWriter.ts.
- Add tsc --noEmit as the "typecheck" script, plus a minimal ambient
  declaration for the untyped 'm3u' package so it passes under strict
  mode.
- Add AGENTS.md, CONTRIBUTING.md, and PLANNING/ (previously untracked)
  documenting the branch/PR workflow and the full rework task list.

Closes #1
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EncvBjUkvZfEutPhyYJHeB
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 1-fix-path-sanitization-bugs:1-fix-path-sanitization-bugs
git switch 1-fix-path-sanitization-bugs

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff 1-fix-path-sanitization-bugs
git switch 1-fix-path-sanitization-bugs
git rebase master
git switch master
git merge --ff-only 1-fix-path-sanitization-bugs
git switch 1-fix-path-sanitization-bugs
git rebase master
git switch master
git merge --no-ff 1-fix-path-sanitization-bugs
git switch master
git merge --squash 1-fix-path-sanitization-bugs
git switch master
git merge --ff-only 1-fix-path-sanitization-bugs
git switch master
git merge 1-fix-path-sanitization-bugs
git push origin master
Sign in to join this conversation.
No reviewers
No labels
m3u_files
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jshaver/jellyfin-to-m3u!7
No description provided.