Skip to content

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

:bug: Fix a NPE in OCR

Daniel5cd46fd7a6e9
diff --git a/kernel/util/ocr.go b/kernel/util/ocr.go
index 4a75a7c2ad..f4fc44a7d0 100644
--- a/kernel/util/ocr.go
+++ b/kernel/util/ocr.go
@@ -242,8 +242,13 @@ func Tesseract(imgAbsPath string) (ret []map[string]interface{}) {
fields := strings.Split(line, "\t")
// 将字段名和字段值映射到一个 map 中
dataMap := make(map[string]interface{})
- for i, header := range strings.Split(lines[0], "\t") {
- dataMap[header] = fields[i]
+ headers := strings.Split(lines[0], "\t")
+ for i, header := range headers {
+ if i < len(fields) {
+ dataMap[header] = fields[i]
+ } else {
+ dataMap[header] = ""
+ }
}
ret = append(ret, dataMap)
}