Repository navigation
test: staterc values are escaped and safe to source - #41
Open
EnzoItaliano wants to merge 8 commits into
Open
EnzoItaliano wants to merge 8 commits into
EnzoItaliano wants to merge 8 commits into
Conversation
Covers staterc.sh and set_conf(): fresh install, replace in place, duplicate keys collapsed, literal values (/, &, |, backslash, %), usage errors, 40 concurrent writers losing nothing, mode kept, a failed write leaving staterc unchanged, and set_conf() going through the helper.
check_staterc_waybar.py runs 20 Python and 20 bash writers at once and checks nothing is lost, plus a fresh install, duplicate keys, a failed replace leaving staterc intact, ensure_state_file() not deadlocking on the lock, and the file mode being kept. test_staterc.sh runs it.
staterc_harness.lua checks staterc_set() on a fresh install, a value with a quote, slash, ampersand and backslash, and a refused key leaving staterc untouched. test_staterc.sh runs it, then 10 Lua and 10 bash writers at once, and skips when lua or lfs is unavailable.
test_staterc.sh holds staterc.lock and checks that staterc.sh prints its timeout warning and writes; check_staterc_waybar.py makes staterc.lock unopenable and checks that set_state_value() still writes.
…urrent ones Case 8: with only WAYBAR_LAYOUT_PATH in staterc, the name and style are filled in from it. Case 9: a layout another writer sets while ensure_state_file() works out its values is not overwritten.
9 of 16 tasks
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Tests for HyDE-Project/HyDE#2197. staterc is read with
source, but its writers didn't escape values: a$(...)or backtick in a value (for example a theme's directory name, saved asHYDE_THEME) ran as a command, and a"broke the file. The companion HyDE PR writesKEY="value"with\ " $and the backtick escaped everywhere, and the Lua and Python readers undo it.test_staterc.sh, case 13 (staterc.sh):a"b,$(touch …), a backtick command,a\b,\,a\,",$HOME,x\$yand an empty value each read back unchanged bysource, and neither command runs;Gruvbox Retro) is written exactly as before;Case 9 (
set_conf()with a backslash) now expects the escaped line, and also checks thatsourcereads it back asback\slash.lua/staterc_harness.lua, cases 4–6 (staterc_get()):staterc_set()andstaterc_get(), and a newline is refused;K="back\slash"reads assourcereads it;check_staterc_waybar.py(waybar.py):set_state_value()andget_state_value(), an old unquoted path with a space still reads, a newline raisesValueErrorand leaves the file untouched, and_add_missing_state_values()escapes too;waybar.pywrites is read back bysourcewithout running anything, and whatstaterc.shwrites is read back bywaybar.py.On HyDE dev @ 90bffa6d this fails: the commands run, a
"breaks sourcing, andwaybar.pywrites unquoted lines. With the companion PR it passes.This branch builds on #40 (the staterc lock tests, still open), so until #40 is merged its commits show here too. It merges cleanly with
main; the full suite onmainplus this branch, against the HyDE PR, is 60 cases, 0 failed.Companion HyDE PR: HyDE-Project/HyDE#2198
Type of change
Checklist