You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
realpath -m / readlink -m: a relative .. never goes above the current directory #1908
Without -m the answer is right (realpath .. prints /c/Windows), and so is an absolute operand (realpath -m /c/Windows/System32/.. prints /c/Windows). WinuxCmd 1.2.1 printed C:\Windows for realpath -m ...
Scripts that resolve a path with realpath -m before checking it (for example, refusing to walk a drive root) get the current directory back for ../.. and let it through.
WinuxCmd 1.2.3 (WinuxCmd-1.2.3-win-x64.tar.gz), Windows 11.
The issue was drafted with Claude and the reproductions were run on the versions above.
Fixed by #1918 (merged 24c6eb6): normalize_lex_native now starts relative -m forms from the cwd components, so .. ascends again; anchor roots are never popped. Verified fail-first both ways with 3 new pins; CI all green.
Activity
caomengxuan666 commentedon Nov 28, 2026
队长分拣:确认本方 bug(回归)(建议 P2;报告人指出的「先 realpath -m 再做路径守卫」被绕过场景属实)。
两侧实测:
realpath -m ..→ /home/cmx;realpath -m ../..→ /home;realpath -m ../x→ /home/cmx/x;readlink -m ..→ /home/cmx。相对..在 -m 下按词法上行。realpath -m ..→C:\Windows、realpath -m ../..→C:\、realpath -m ../x→C:\Windows\x、readlink -m ..→C:/Windows(上行正确;仅 realpath 输出为 native 反斜杠形,与报告人记的 1.2.1 行为一致)。rust2/crates/winux-cmds/src/canon.rs的normalize_lex_native对相对操作数以空 stack 起步做词法行走,..只弹操作数自身的分量、永不弹 cwd 的分量——..得 cwd 本身、../..仍是 cwd、../x得 cwd/x,与 1.2.3 输出逐条吻合。说明:队长装机只有 1.2.1,未能在装机上实跑 1.2.3 的坏形;坏形由报告人实测 + master 源码路径同形双证。回归窗为 1.2.1 → 1.2.3(rust2 canon 移植波)。
修复方向:-m 词法行走应以 cwd 的分量作为初始 stack(在盘符根处钳制),使前导
..能上行出 cwd;readlink -m 共用同一canonicalize_operand,一并受益。补钉请带相对..跨出 cwd 的用例(现 gate 的 realpath/readlink TSV 未覆盖此形)。— 队长分拣
fix(canon): realpath -m relative .. ascends from cwd again (Refs #1908)…
caomengxuan666 commentedon Nov 28, 2026
Fixed by #1918 (merged 24c6eb6):
normalize_lex_nativenow starts relative-mforms from the cwd components, so..ascends again; anchor roots are never popped. Verified fail-first both ways with 3 new pins; CI all green.rust2(port+wire): cat -> rust2 library + bridge (#1488) (#1882)
rust2(port+wire): uniq -> rust2 library + bridge (#1488) (#1877)