Commit 8417a35
committed
fix: escape control characters in IfcfgUtil.ValueEscape
The ANSI-C quoting branch tested `ord(c) < ord(c)`, which is always
False, so the escaping path was dead and control characters were
written raw into the $'...' string. ifcfg_to_content() emits one
KEY=VALUE per line, so a value containing a newline broke that
structure in the generated file.
The escape also emitted a decimal code point, but ANSI-C quoting
reads \nnn as octal, so the sequence would have decoded to the wrong
character once the branch became reachable. Both are corrected by
comparing against ord(" ") and emitting %03o.
Adds unit tests covering the ANSI-C path, the double-quoting path and
the unquoted path. The two control-character tests fail without the
fix.
Documents the escaping rules in the ValueEscape docstring, citing
Bash Reference Manual 3.1.2.3 and 3.1.2.4.
Signed-off-by: Suraj Patil <surajpatil522@gmail.com>1 parent 88fd7be commit 8417a35
2 files changed
Lines changed: 33 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
305 | 321 | | |
306 | 322 | | |
307 | 323 | | |
| |||
314 | 330 | | |
315 | 331 | | |
316 | 332 | | |
317 | | - | |
318 | | - | |
| 333 | + | |
| 334 | + | |
319 | 335 | | |
320 | 336 | | |
321 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5657 | 5657 | | |
5658 | 5658 | | |
5659 | 5659 | | |
| 5660 | + | |
| 5661 | + | |
| 5662 | + | |
| 5663 | + | |
| 5664 | + | |
| 5665 | + | |
| 5666 | + | |
| 5667 | + | |
| 5668 | + | |
| 5669 | + | |
| 5670 | + | |
| 5671 | + | |
| 5672 | + | |
| 5673 | + | |
5660 | 5674 | | |
5661 | 5675 | | |
0 commit comments