Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ To copy a default config to user config with automatic backup:
omarchy-refresh-config hypr/hyprland.lua
```

This copies `$OMARCHY_PATH/config/hypr/hyprland.lua` to `~/.config/hypr/hyprland.lua`. The argument must be a plain relative path: an absolute path or any `..` segment is rejected before anything is copied. That check is lexical, so a symlink under `~/.config` is still followed and its target rewritten — which is what keeps symlink-managed dotfiles working.
This copies `$OMARCHY_PATH/config/hypr/hyprland.lua` to `~/.config/hypr/hyprland.lua`. The argument must be a plain relative path: an absolute path, any `..` segment, or a line break is rejected before anything is copied. That check is lexical, so a symlink under `~/.config` is still followed and its target rewritten — which is what keeps symlink-managed dotfiles working.
4 changes: 3 additions & 1 deletion bin/omarchy-refresh-config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ USAGE
exit 1
fi

if [[ $config_file == /* || $config_file == ".." || $config_file == ../* || $config_file == */../* || $config_file == */.. ]]; then
# Absolute paths, `..` segments, and line breaks are not shipped relative
# configs. A `..` component can land the write outside ~/.config.
if [[ $config_file == /* || $config_file == ".." || $config_file == ../* || $config_file == */../* || $config_file == */.. || $config_file == *$'\n'* || $config_file == *$'\r'* ]]; then
echo "Invalid config path: $config_file" >&2
exit 1
fi
Expand Down
8 changes: 7 additions & 1 deletion test/shell.d/refresh-config-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ refuses() {
fail "refresh-config rejects $config_file"
fi

grep -Fq "Invalid config path: $config_file" "$tmpdir/err" ||
[[ $(cat "$tmpdir/err") == "Invalid config path: $config_file" ]] ||
fail "refresh-config reports $config_file as an invalid config path" "$(cat "$tmpdir/err")"

[[ $(cat "$escape") == "do not touch" ]] ||
Expand All @@ -65,5 +65,11 @@ refuses hypr/../../escape
refuses ..
refuses hypr/..
refuses /etc/passwd
refuses $'hypr\n/../../escape'
newline_path=$'hypr/a\nb.lua'
printf 'shipped newline config\n' >"$omarchy_path/config/$newline_path"
refuses "$newline_path"
[[ ! -e $home/.config/$newline_path ]] || fail "newline path must not be copied"
refuses $'hypr/a\rb.lua'

pass "refresh-config rejects paths escaping .config"