mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
fix: serialize patches inside double quotes if there are variables inside (#137)
Old behaviour leads to variable to be serialized always in single quotes (if shlex decides to quote it). It doesn't allow to expand variables during execution, so those values should be put inside double quotes instead. This commit checks if there is sign char in the variable and quotes manually, otherwise returning shlex call
This commit is contained in:
@ -34,14 +34,6 @@ def test_is_plain_diff() -> None:
|
||||
assert PkgbuildPatch(None, "value").is_plain_diff
|
||||
|
||||
|
||||
def test_quote() -> None:
|
||||
"""
|
||||
must quote strings if unsafe flag is not set
|
||||
"""
|
||||
assert PkgbuildPatch.quote("value") == """value"""
|
||||
assert PkgbuildPatch.quote("va'lue") == """'va'"'"'lue'"""
|
||||
|
||||
|
||||
def test_from_env() -> None:
|
||||
"""
|
||||
must construct patch from environment variable
|
||||
@ -71,6 +63,16 @@ def test_parse() -> None:
|
||||
assert PkgbuildPatch.parse("key", json.dumps(["array", "value"])).value == ["array", "value"]
|
||||
|
||||
|
||||
def test_quote() -> None:
|
||||
"""
|
||||
must quote strings if unsafe flag is not set
|
||||
"""
|
||||
assert PkgbuildPatch.quote("value") == """value"""
|
||||
assert PkgbuildPatch.quote("va'lue") == """'va'"'"'lue'"""
|
||||
assert PkgbuildPatch.quote("https://github.com/arcan1s/ahriman/releases/download/$pkgver/$pkgbase-$pkgver.tar.gz") == \
|
||||
"""\"https://github.com/arcan1s/ahriman/releases/download/$pkgver/$pkgbase-$pkgver.tar.gz\""""
|
||||
|
||||
|
||||
def test_unquote() -> None:
|
||||
"""
|
||||
must remove quotation marks
|
||||
|
Reference in New Issue
Block a user