mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
🐛 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>
This commit is contained in:
parent
43c8ccb96b
commit
bc238a245f
1 changed files with 10 additions and 7 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue