Skip to content

Commit

Permalink
Disable value interpolation in configparser
Browse files Browse the repository at this point in the history
The metadata is a text file and cannot use $ or %. A % can occur in
uri value of Extra Data which can't be parsed with interpolation
enabled
  • Loading branch information
bbhtt committed Dec 2, 2023
1 parent 9c2a70d commit 4fca19e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flatpak_builder_lint/builddir.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_metadata(builddir: str) -> dict:


def parse_metadata(ini: str) -> dict:
parser = ConfigParser()
parser = ConfigParser(interpolation=None)
parser.optionxform = str # type: ignore
parser.read_string(ini)

Expand Down
17 changes: 17 additions & 0 deletions tests/builddir/metadata-spaces/metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Application]
name=org.flathub.example-spaces
command=example spaces

[Context]
persistent=.foo bar
filesystems=~/foo bar

[Extra Data]
name=example spaces.ext
checksum=b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
size=1
uri=https://example.org/foo%20bar.ext
name1=example%20spaces.ext
checksum1=1f2ec52b774368781bed1d1fb140a92e0eb6348090619c9291f9a5a3c8e8d151
size1=1
uri1=https://example.org/foo bar.ext
12 changes: 12 additions & 0 deletions tests/test_builddir.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,15 @@ def test_builddir_console() -> None:
found_errors = set(ret["errors"])

assert errors == found_errors

def test_builddir_metadata_spaces() -> None:
errors = {
"appstream-metainfo-missing",
"appstream-missing-icon-file",
"appstream-missing-appinfo-file"
}

ret = run_checks("tests/builddir/metadata-spaces")
found_errors = set(ret["errors"])

assert errors.issubset(found_errors)

0 comments on commit 4fca19e

Please sign in to comment.