diff --git a/scripts/inert-lo.sh b/scripts/inert-lo.sh index 25f878c..08dd91d 100755 --- a/scripts/inert-lo.sh +++ b/scripts/inert-lo.sh @@ -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 diff --git a/tests/scripts/lo-unregistered.sh b/tests/scripts/lo-unregistered.sh index eb25183..bda096f 100755 --- a/tests/scripts/lo-unregistered.sh +++ b/tests/scripts/lo-unregistered.sh @@ -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