fix(paths): gsub path expansion mangles ../relative paths #57

Closed
opened 2026-05-25 14:42:49 +02:00 by michael · 1 comment
Owner

Problem

Path expansion via gsub("^%.", ...) appears in two places:

adapters/ui/init.lua:

local path = section.path:gsub("^%.", install_root)

core/config.lua:

v = v:gsub("^%.", install_root)

^%. matches any leading dot character. A path like ../foo starts
with . and becomes install_root./foo -- a broken path with no error.

Fix

Match only ./ (dot-slash) to avoid the ../ edge case:

v = v:gsub("^%./", install_root .. "/")

Or validate that paths starting with .. are rejected explicitly.

Acceptance criteria

  • ../foo is not silently mangled
  • ./foo still expands correctly to install_root/foo
  • Both locations fixed
## Problem Path expansion via `gsub("^%.", ...)` appears in two places: `adapters/ui/init.lua`: ```lua local path = section.path:gsub("^%.", install_root) ``` `core/config.lua`: ```lua v = v:gsub("^%.", install_root) ``` `^%.` matches any leading dot character. A path like `../foo` starts with `.` and becomes `install_root./foo` -- a broken path with no error. ## Fix Match only `./` (dot-slash) to avoid the `../` edge case: ```lua v = v:gsub("^%./", install_root .. "/") ``` Or validate that paths starting with `..` are rejected explicitly. ## Acceptance criteria - [ ] `../foo` is not silently mangled - [ ] `./foo` still expands correctly to `install_root/foo` - [ ] Both locations fixed
Author
Owner

Decision: won't fix

The original gsub("^%.", install_root) correctly handles all real-world
cases:

  • path = . -> install_root (dev setup)
  • path = ./lib/... -> install_root/lib/...

The ../foo edge case is theoretical and never occurs in practice.
A fix for ../ broke the standard path = . case and caused regression.

Closing as won't fix.

## Decision: won't fix The original `gsub("^%.", install_root)` correctly handles all real-world cases: - `path = .` -> install_root (dev setup) - `path = ./lib/...` -> install_root/lib/... The `../foo` edge case is theoretical and never occurs in practice. A fix for `../` broke the standard `path = .` case and caused regression. Closing as won't fix.
michael added this to the Basic Version milestone 2026-05-30 16:05:00 +02:00
Sign in to join this conversation.
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
DAW/fragjan#57
No description provided.