Inert step refuses an unreadable plist; guard runs it on a fake bundle (R2.15)
This commit is contained in:
2 files changed
+10
-1
No files matched your search
+1
-1
@@ -3,7 +3,7 @@
|
||||
set -euo pipefail
|
||||
app=${1:?usage: scripts/inert-lo.sh path/to/LibreOffice.app}
|
||||
plist=$app/Contents/Info.plist
|
||||
[ -f "$plist" ] || { echo "inert-lo.sh: no $plist" >&2; exit 1; }
|
||||
plutil -lint -s "$plist" || { echo "inert-lo.sh: $plist is missing or unreadable" >&2; exit 1; }
|
||||
lsregister=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
|
||||
for key in CFBundleDocumentTypes CFBundleURLTypes UTExportedTypeDeclarations UTImportedTypeDeclarations; do
|
||||
if /usr/libexec/PlistBuddy -c "Print :$key" "$plist" >/dev/null 2>&1; then
|
||||
|
||||
@@ -14,6 +14,15 @@ if [ -d "$app" ]; then
|
||||
fi
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
fake=$work/a/b/Fake.app
|
||||
mkdir -p "$fake/Contents/PlugIns"
|
||||
echo "not a plist" >"$fake/Contents/Info.plist"
|
||||
! "$root/scripts/inert-lo.sh" "$fake" 2>/dev/null || fail "inert-lo.sh accepts an unreadable Info.plist"
|
||||
plutil -create xml1 "$fake/Contents/Info.plist"
|
||||
plutil -insert CFBundleDocumentTypes -array "$fake/Contents/Info.plist"
|
||||
"$root/scripts/inert-lo.sh" "$fake" >/dev/null
|
||||
! /usr/libexec/PlistBuddy -c "Print :CFBundleDocumentTypes" "$fake/Contents/Info.plist" >/dev/null 2>&1 || fail "inert-lo.sh left a claim"
|
||||
[ ! -e "$fake/Contents/PlugIns" ] || fail "inert-lo.sh left the plug-ins"
|
||||
for ext in docx xlsx pptx odt csv; do : >"$work/sample.$ext"; done
|
||||
cat >"$work/open.swift" <<'SWIFT'
|
||||
import AppKit
|
||||
|
||||
Reference in new issue
Block a user