RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix empty Markdown document parsing (#18503)
Jiang, Guomin9e913c3fb015
diff --git a/rag/app/naive.py b/rag/app/naive.pyindex 7479b2dc32..ffd37266f4 100644--- a/rag/app/naive.py+++ b/rag/app/naive.py@@ -894,7 +894,7 @@ class Markdown(MarkdownParser):def __call__(self, filename, binary=None, separate_tables=True, delimiter=None, return_section_images=False):"""Parse markdown into text sections and optional standalone table chunks."""- if binary:+ if binary is not None:encoding = find_codec(binary)txt = binary.decode(encoding, errors="ignore")else:diff --git a/test/unit_test/rag/app/test_markdown_image_ssrf.py b/test/unit_test/rag/app/test_markdown_image_ssrf.pyindex 2c3d2d119f..f738421d23 100644--- a/test/unit_test/rag/app/test_markdown_image_ssrf.py+++ b/test/unit_test/rag/app/test_markdown_image_ssrf.py@@ -91,6 +91,21 @@ def parser(naive_module):return naive_module.Markdown(128)+def test_parses_empty_binary_without_opening_filename(parser):+ with patch("builtins.open") as open_file:+ sections, tables, section_images = parser(+ "empty-document.md",+ binary=b"",+ return_section_images=True,+ )++ open_file.assert_not_called()+ assert sections == []+ assert tables == []+ assert section_images == []++@pytest.mark.p1def test_blocks_internal_url_without_fetching(parser):"""A markdown image pointing at an internal host must never be requested."""