Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: accept .markdown files in upload whitelist (#20850)

Heran Liu2068a65ec305
diff --git a/internal/utility/file.go b/internal/utility/file.go
index 774c92499d..c6cd3902d9 100644
--- a/internal/utility/file.go
+++ b/internal/utility/file.go
@@ -68,6 +68,8 @@ func normalizeFilename(filename string) (string, bool) {
return strings.ToLower(base), true
}
+// GetFileType classifies a filename by its case-insensitive extension.
+// It returns FileTypeOTHER when the extension is missing or unsupported.
func GetFileType(filename string) FileType {
ext := filepath.Ext(filename)
@@ -125,6 +127,9 @@ func GetFileType(filename string) FileType {
}
}
+// FilenameType returns the upload category for a filename.
+// It classifies supported extensions and returns FileTypeOTHER for invalid
+// filenames or unsupported extensions.
func FilenameType(filename string) FileType {
normalized, ok := normalizeFilename(filename)
if !ok {
@@ -138,7 +143,7 @@ func FilenameType(filename string) FileType {
docExtensions := []string{
"msg", "eml", "doc", "docx", "ppt", "pptx", "yml", "xml", "htm", "json", "jsonl", "ldjson",
"csv", "txt", "ini", "xls", "xlsx", "wps", "rtf", "hlp", "pages", "numbers", "key",
- "md", "mdx", "py", "js", "java", "c", "cpp", "h", "php", "go", "ts", "sh", "cs", "kt",
+ "md", "markdown", "mdx", "py", "js", "java", "c", "cpp", "h", "php", "go", "ts", "sh", "cs", "kt",
"html", "sql", "epub",
}
for _, ext := range docExtensions {
diff --git a/internal/utility/markdown_extension_test.go b/internal/utility/markdown_extension_test.go
new file mode 100644
index 0000000000..9c4d6d911b
--- /dev/null
+++ b/internal/utility/markdown_extension_test.go
@@ -0,0 +1,44 @@
+//
+// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package utility
+
+import "testing"
+
+// TestMarkdownUploadAliases verifies that supported Markdown aliases retain
+// Markdown parser selection and pass the document upload gate.
+func TestMarkdownUploadAliases(t *testing.T) {
+ for _, name := range []string{"notes.markdown", "NOTES.MARKDOWN", "folder/notes.markdown", "notes.md", "notes.mdx"} {
+ t.Run(name, func(t *testing.T) {
+ if got := GetFileType(name); got != FileTypeMarkdown {
+ t.Fatalf("parser classifies %q as %q, want Markdown", name, got)
+ }
+ if got := FilenameType(name); got != FileTypeDOC {
+ t.Fatalf("upload gate classifies %q as %q, want document", name, got)
+ }
+ })
+ }
+}
+
+// TestUnsupportedFilenameRemainsRejected verifies that executable filenames and
+// unsupported Markdown-like suffixes are rejected by the upload classifier.
+func TestUnsupportedFilenameRemainsRejected(t *testing.T) {
+ for _, name := range []string{"payload.exe", "notes.markdown.exe", "notes.markdownx"} {
+ if got := FilenameType(name); got != FileTypeOTHER {
+ t.Errorf("FilenameType(%q) = %q, want other", name, got)
+ }
+ }
+}