Skip to content

Commit ff44bf3

Browse files
committed
fix: escape special characters in restore_ini sed replacement
- Add escaping for &, /, and \ in values restored from backup - Prevent sed substitution from breaking when URLs or special chars are present
1 parent 6a3acff commit ff44bf3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

customize.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,13 @@ restore_ini() {
197197
for key in $keys; do
198198
value=$(grep "^$key=" "$backup_ini")
199199
if [ -n "$value" ]; then
200+
# Escape special characters to make it safe for sed
201+
esc_value=$(printf '%s\n' "$value" | sed -e 's/[&/\]/\\&/g')
202+
200203
if grep -q "^$key=" "$target_ini"; then
201204
# Replace old line
202-
sed -i "s|^$key=.*|$value|" "$target_ini"
205+
# sed -i "s|^$key=.*|$value|" "$target_ini"
206+
sed -i "s|^$key=.*|$esc_value|" "$target_ini"
203207
else
204208
# Append at the end of the file
205209
echo "$value" >> "$target_ini"

0 commit comments

Comments
 (0)