xdg-mime-apps: fix regex in mimeAssociations

The XDG Desktop Entry spec mentions that multiple values per key may be
optionally terminated by a semicolon. An example for this is the Firefox
desktop file, which has no trailing semicolon. This breaks the sed regex
used in `mimeAssociations`.

Fix the regex by matching the end of string, optionally preceded by a
semicolon, or any other semicolon. This makes it work with both
semicolon-terminated and non-semicolon-terminated desktop files.
This commit is contained in:
Tom Wieczorek 2022-07-26 10:08:25 +02:00 committed by Tom Wieczorek
parent dbed4c794d
commit 0b7fd187e2
No known key found for this signature in database
GPG key ID: FE33A2282371E831

View file

@ -94,7 +94,7 @@ in {
for p in $ps ; do
for path in "$p"/share/applications/*.desktop ; do
name="''${path##*/}"
sed -n "/^MimeType=/ { s/.*=//; s/;/;$name\n/g; p; }" "$path"
sed -n -E "/^MimeType=/ { s/.*=//; s/;?$|;/;$name\n/g; p; }" "$path"
done
done > "$out"
'';