Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Fix Built-in Pandoc is not working on Unix-like Fix https://github.com/siyuan-note/siyuan/issues/16623

Danielbc238a245f44
diff --git a/kernel/util/pandoc.go b/kernel/util/pandoc.go
index 300fe54997..2d9053789a 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"