Safely escape values written through sed - #610
Merged
ExtremeFiretop merged 1 commit intoSep 24, 2026
Merged
Conversation
maghuro
requested review from
ExtremeFiretop and
Martinski4GitHub
as code owners
September 23, 2026 22:51
maghuro
force-pushed
the
fix/settings-sed-escaping
branch
from
September 24, 2026 00:48
3029456 to
190edc6
Compare
Owner
|
Considering this PR basically does nothing but extend your existing fix from PR: I'll merge it in as is. |
ExtremeFiretop
approved these changes
Sep 24, 2026
ExtremeFiretop
added a commit
that referenced
this pull request
Sep 24, 2026
Owner
|
I extended this PR even further in commit: 4e779db |
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.
Summary
Safely escape configuration values before using them in sed replacement expressions.
Problem
Update_Custom_Settings() writes several setting values back into the configuration file using sed substitutions.
One path currently escapes a set of characters that does not include ampersand.
In a sed replacement expression, ampersand has special meaning: it expands to the entire text matched by the search expression.
For example, a setting value such as:
can corrupt the configuration line because the ampersand is interpreted by sed instead of being written literally.
Backslashes also have special meaning in sed replacement strings and need to be escaped consistently.
Fix
Before inserting setting values into sed replacement expressions, escape the three characters that are significant for this usage:
The same escaping expression is now used consistently by all three replacement paths in Update_Custom_Settings().
The value is also passed through printf instead of echo so that its contents are not subject to implementation-specific echo escape handling.
Validation
The replacement behavior was tested with both regular sed and BusyBox sed using values containing:
Values are preserved correctly in the resulting configuration assignment.
The previous behavior with an ampersand was also reproduced and resulted in configuration-line corruption.