-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove escaping of backslashes to support literal ${var}
THIS IS A BACKWARDS INCOMPATIBLE CHANGE THAT AFFECTS FW FILE CREATION. It does not affect processing of fw files so you don't need to worry about change fwup versions on existing devices or worry about applying .fw files created with old versions of fwup. Automatic escaping of backslashes made it impossible to write `${var}` to a U-Boot variable. Here's why. When doing this, you have to remember that `fwup` evaluates variable substitution twice - once when making the .fw file and once when applying it. You obviously have to escape the `$` when creating the .fw file. That made sense. Then to survive the apply step, you'd think that you could double escape the `$`. You'd be wrong, though, since `fwup` was escaping the backslashes that you were adding writing the configuration to the .fw file. Therefore, the variable substitution was guaranteed to happen since you couldn't double escape a `$`. Amazingly, the auto-escaping behavior was only tested in the regression tests via the exec test on Windows - a combination that would never be used for real. When you run into this issue, it's weird enough to be pretty confusing, imho. Hopefully that and how rare should have been in real uses cases makes this something that no one actually did. This changes string processing to not automatically escape backslashes when creating the .fw file. It is possible to escape a `$` through to the end. This allows you to write a U-Boot environment variable with a `${var}` in it. This also locks down string processing behaviors by adding unit tests.
- Loading branch information
Showing
5 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Test environment variables embedded in strings in the config files | ||
# | ||
# If this fails, you're using an old version of libconfuse. This is sadly | ||
# very common. See the readme, but the basic fix is to go to the libconfuse | ||
# GitHub and build it yourself. | ||
# | ||
|
||
. "$(cd "$(dirname "$0")" && pwd)/common.sh" | ||
|
||
export TEST_ENV_VAR=1K.bin | ||
|
||
cat >$CONFIG <<EOF | ||
# Escape sequence in double quotes | ||
meta-product = "Octal \044 and hex \x3c" | ||
# Backslashes are escaped | ||
meta-description = "\\\\$" | ||
# Escape sequences and variables dont get processed in single quotes | ||
meta-version = '\044 \x3c \${}' | ||
# Substitution happens in double quotes | ||
meta-author = "Substitution \${}" | ||
# Escapes quotes in double quotes (fwup weird behavior 1) | ||
meta-platform = "\"\"" | ||
# Escapes quotes in single quotes (fwup weird behavior 2) | ||
meta-architecture = '""' | ||
EOF | ||
|
||
cat >$EXPECTED_META_CONF <<EOF | ||
meta-product="Octal $ and hex <" | ||
meta-description="\\$" | ||
meta-version="\044 \x3c \${}" | ||
meta-author="Substitution" | ||
meta-platform="\"\"" | ||
meta-architecture="\"\"" | ||
EOF | ||
|
||
$FWUP_CREATE -c -f $CONFIG -o $FWFILE | ||
|
||
# Check that the zip file was created as expected | ||
check_meta_conf | ||
|
||
# Check that the verify logic works on this file | ||
$FWUP_VERIFY -V -i $FWFILE |
This file contains 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