mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
lib/init.sh: sanitize the version string
the release functions in release.sh rely on the version string *not* being a path containing slashes. just a single string e.g. "foo", not e.g. "foo/bar" this is because several checks there make that assumption. in practise, we always ensure that tags and such do not contain these characters. however, someone else working on their own version of xbmk might not know of this design flaw, so let's try to correct it in code. we can add more filtering as designed, in the relevant function (xbmk_sanitize_version). Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -22,10 +22,26 @@ mkrom_tarball()
|
||||
|
||||
update_xbmkver()
|
||||
{
|
||||
xbmk_sanitize_version
|
||||
|
||||
printf "%s\n" "$version" > "$1/.version" || err "$1 !version"; :
|
||||
printf "%s\n" "$versiondate" > "$1/.versiondate" || err "$1 !vdate"; :
|
||||
}
|
||||
|
||||
xbmk_sanitize_version()
|
||||
{
|
||||
[ -n "$version" ] || return 0; :
|
||||
|
||||
version="`printf "%s\n" "$version" | sed -e 's/\t//g'`"
|
||||
version="`printf "%s\n" "$version" | sed -e 's/\ //g'`"
|
||||
version="`printf "%s\n" "$version" | sed -e 's/\.\.//g'`"
|
||||
version="`printf "%s\n" "$version" | sed -e 's/\.\///g'`"
|
||||
version="`printf "%s\n" "$version" | sed -e 's/\//-/g'`"
|
||||
version="${version#-}"
|
||||
|
||||
[ -n "$version" ] || err "'version' empty after sanitization"; :
|
||||
}
|
||||
|
||||
mktarball()
|
||||
{
|
||||
printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1"
|
||||
|
||||
Reference in New Issue
Block a user