From bc238a245f447fc31f7348d934f9928b4f6bdaaa Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 19 Dec 2025 20:13:57 +0800 Subject: [PATCH] :bug: Fix Built-in Pandoc is not working on Unix-like Fix https://github.com/siyuan-note/siyuan/issues/16623 Signed-off-by: Daniel <845765@qq.com> --- kernel/util/pandoc.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/util/pandoc.go b/kernel/util/pandoc.go index 300fe5499..2d9053789 100644 --- a/kernel/util/pandoc.go +++ b/kernel/util/pandoc.go @@ -239,17 +239,20 @@ func IsValidPandocBin(binPath string) bool { } isBin := false - // 常见二进制魔数:ELF, PE("MZ"), Mach-O/FAT + // 常见二进制魔数:ELF, PE("MZ"), Mach-O (32/64, big/little), FAT if len(header) >= 4 { switch { case bytes.Equal(header[:4], []byte{0x7f, 'E', 'L', 'F'}): isBin = true // ELF - case bytes.Equal(header[:4], []byte{0xfe, 0xed, 0xfa, 0xce}): - isBin = true // Mach-O - case bytes.Equal(header[:4], []byte{0xce, 0xfa, 0xed, 0xfe}): - isBin = true // Mach-O (swapped) - case bytes.Equal(header[:4], []byte{0xca, 0xfe, 0xba, 0xbe}): - isBin = true // FAT + // Mach-O / Mach-O swapped (32-bit) + case bytes.Equal(header[:4], []byte{0xfe, 0xed, 0xfa, 0xce}), bytes.Equal(header[:4], []byte{0xce, 0xfa, 0xed, 0xfe}): + isBin = true + // Mach-O 64-bit / swapped + case bytes.Equal(header[:4], []byte{0xfe, 0xed, 0xfa, 0xcf}), bytes.Equal(header[:4], []byte{0xcf, 0xfa, 0xed, 0xfe}): + isBin = true + // FAT / FAT swapped + case bytes.Equal(header[:4], []byte{0xca, 0xfe, 0xba, 0xbe}), bytes.Equal(header[:4], []byte{0xbe, 0xba, 0xfe, 0xca}): + isBin = true } } // PE only needs first 2 bytes "MZ"