diff --git a/internal/infrastructure/docparser/mineru_cloud_converter.go b/internal/infrastructure/docparser/mineru_cloud_converter.go
index 133d2aec05..a82b9cbdab 100644
--- a/internal/infrastructure/docparser/mineru_cloud_converter.go
+++ b/internal/infrastructure/docparser/mineru_cloud_converter.go
@@ -350,7 +350,10 @@ func (c *MinerUCloudReader) extractDoneResult(_ context.Context, item *extractRe
// --- ZIP handling ---
-var imgRefPattern = regexp.MustCompile(`!\[[^\]]*\]\(([^)]+)\)`)
+var (
+ imgRefPattern = regexp.MustCompile(`!\[[^\]]*\]\(([^)]+)\)`)
+ htmlImgRefPattern = regexp.MustCompile(`(?i)]*\ssrc\s*=\s*(?:"([^"]+)"|'([^']+)')`)
+)
func downloadAndExtractZip(zipURL string) (string, []types.ImageRef, error) {
if err := utils.ValidateURLForSSRF(zipURL); err != nil {
@@ -406,8 +409,19 @@ func downloadAndExtractZip(zipURL string) (string, []types.ImageRef, error) {
// Extract referenced images
var imageRefs []types.ImageRef
seen := map[string]bool{}
+ var referencedPaths []string
for _, match := range imgRefPattern.FindAllStringSubmatch(mdText, -1) {
+ referencedPaths = append(referencedPaths, match[1])
+ }
+ for _, match := range htmlImgRefPattern.FindAllStringSubmatch(mdText, -1) {
imgPath := match[1]
+ if imgPath == "" {
+ imgPath = match[2]
+ }
+ referencedPaths = append(referencedPaths, imgPath)
+ }
+
+ for _, imgPath := range referencedPaths {
if strings.HasPrefix(imgPath, "http://") || strings.HasPrefix(imgPath, "https://") || strings.HasPrefix(imgPath, "data:") {
continue
}
diff --git a/internal/infrastructure/docparser/mineru_cloud_converter_test.go b/internal/infrastructure/docparser/mineru_cloud_converter_test.go
new file mode 100644
index 0000000000..974f306f87
--- /dev/null
+++ b/internal/infrastructure/docparser/mineru_cloud_converter_test.go
@@ -0,0 +1,70 @@
+package docparser
+
+import (
+ "archive/zip"
+ "bytes"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/Tencent/WeKnora/internal/utils"
+)
+
+func TestDownloadAndExtractZipExtractsHTMLImageReferences(t *testing.T) {
+ utils.SetSSRFWhitelistFromRaw("127.0.0.1")
+ t.Cleanup(func() {
+ utils.SetSSRFWhitelistFromRaw("")
+ })
+
+ zipData := buildMinerUCloudTestZip(t, map[string][]byte{
+ "full.md": []byte(`
![]() |