Skip to content

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

feat(utility): route WPS private formats to existing office parsers (#21251)

xugangqiang5b20c9cb6baa
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json b/internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json
index cf5f889a26..6cea29ef4f 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json
@@ -71,7 +71,9 @@
],
"suffix": [
"pptx",
- "ppt"
+ "ppt",
+ "dps",
+ "dpt"
]
}
}
diff --git a/internal/ingestion/task/pipeline_executor_defaults_test.go b/internal/ingestion/task/pipeline_executor_defaults_test.go
index bc88955493..5a0699b5b3 100644
--- a/internal/ingestion/task/pipeline_executor_defaults_test.go
+++ b/internal/ingestion/task/pipeline_executor_defaults_test.go
@@ -47,7 +47,7 @@ var builtinComponentParamsGolden = map[string]string{
"one": "{\"File\": {}, \"Parser:HipSignsRhyme\": {\"enable_vision_enhancement\": false, \"vlm\": {\"llm_id\": \"\"}, \"doc\": {\"preprocess\": [\"main_content\"], \"suffix\": [\"doc\"]}, \"docx\": {\"flatten_media_to_text\": false, \"preprocess\": [\"main_content\"], \"suffix\": [\"docx\"], \"vlm\": {}}, \"html\": {\"preprocess\": [\"main_content\"], \"suffix\": [\"htm\", \"html\"]}, \"markdown\": {\"flatten_media_to_text\": false, \"preprocess\": [\"main_content\"], \"suffix\": [\"md\", \"markdown\", \"mdx\"], \"vlm\": {}}, \"pdf\": {\"flatten_media_to_text\": false, \"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"pdf\"], \"vlm\": {}}, \"spreadsheet\": {\"flatten_media_to_text\": false, \"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"xls\", \"xlsx\"], \"vlm\": {}}, \"text&code\": {\"preprocess\": [\"main_content\"], \"suffix\": [\"txt\"]}}, \"OneChunker:DryDrinksVisit\": {}, \"Tokenizer:FrankWeeksListen\": {\"fields\": \"text\", \"filename_embd_weight\": 0.1, \"search_method\": [\"embedding\", \"full_text\"]}, \"Extractor:AutoExtractDefault\": {\"llm_id\": \"\", \"keywords\": {\"top_n\": 0}, \"questions\": {\"top_n\": 0}, \"tags\": {\"top_n\": 0, \"tag_file_id\": \"\"}, \"summary\": {\"enabled\": false}, \"metadata\": {\"enabled\": false, \"metadata\": [], \"built_in_metadata\": []}}}",
"paper": "{\"File\":{},\"Parser:HipSignsRhyme\":{\"enable_vision_enhancement\":false,\"vlm\":{\"llm_id\":\"\"},\"pdf\":{\"enable_multi_column\":true,\"flatten_media_to_text\":false,\"parse_method\":\"DeepDOC\",\"preprocess\":[\"main_content\"],\"suffix\":[\"pdf\"],\"vlm\":{}}},\"TitleChunker:SparklySchoolsTravel\":{\"hierarchy\":0,\"include_heading_content\":false,\"levels\":[[\"^#[^#]\",\"^##[^#]\",\"^###[^#]\",\"^####[^#]\"],[\"第[零一二三四五六七八九十百0-9]+(分?编|部分)\",\"第[零一二三四五六七八九十百0-9]+章\",\"第[零一二三四五六七八九十百0-9]+节\",\"第[零一二三四五六七八九十百0-9]+条\",\"[\\\\((][零一二三四五六七八九十百]+[\\\\))]\"],[\"第[0-9]+章\",\"第[0-9]+节\",\"[0-9]{1,2}[\\\\. 、]\",\"[0-9]{1,2}\\\\.[0-9]{1,2}($|[^a-zA-Z/%~.-])\",\"[0-9]{1,2}\\\\.[0-9]{1,2}\\\\.[0-9]{1,2}\"],[\"第[零一二三四五六七八九十百0-9]+章\",\"第[零一二三四五六七八九十百0-9]+节\",\"[零一二三四五六七八九十百]+[ 、]\",\"[\\\\((][零一二三四五六七八九十百]+[\\\\))]\",\"[\\\\((][0-9]{,2}[\\\\))]\"],[\"PART (ONE|TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT|NINE|TEN)\",\"Chapter (I+V?|VI*|XI|IX|X)\",\"Section [0-9]+\",\"Article [0-9]+\"]],\"hierarchyRules\":[{\"levels\":[{\"expression\":\"^#[^#]\"},{\"expression\":\"^##[^#]\"},{\"expression\":\"^###[^#]\"},{\"expression\":\"^####[^#]\"}]},{\"levels\":[{\"expression\":\"第[零一二三四五六七八九十百0-9]+(分?编|部分)\"},{\"expression\":\"第[零一二三四五六七八九十百0-9]+章\"},{\"expression\":\"第[零一二三四五六七八九十百0-9]+节\"},{\"expression\":\"第[零一二三四五六七八九十百0-9]+条\"},{\"expression\":\"[\\\\((][零一二三四五六七八九十百]+[\\\\))]\"}]},{\"levels\":[{\"expression\":\"第[0-9]+章\"},{\"expression\":\"第[0-9]+节\"},{\"expression\":\"[0-9]{1,2}[\\\\. 、]\"},{\"expression\":\"[0-9]{1,2}\\\\.[0-9]{1,2}($|[^a-zA-Z/%~.-])\"},{\"expression\":\"[0-9]{1,2}\\\\.[0-9]{1,2}\\\\.[0-9]{1,2}\"}]},{\"levels\":[{\"expression\":\"第[零一二三四五六七八九十百0-9]+章\"},{\"expression\":\"第[零一二三四五六七八九十百0-9]+节\"},{\"expression\":\"[零一二三四五六七八九十百]+[ 、]\"},{\"expression\":\"[\\\\((][零一二三四五六七八九十百]+[\\\\))]\"},{\"expression\":\"[\\\\((][0-9]{,2}[\\\\))]\"}]},{\"levels\":[{\"expression\":\"PART (ONE|TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT|NINE|TEN)\"},{\"expression\":\"Chapter (I+V?|VI*|XI|IX|X)\"},{\"expression\":\"Section [0-9]+\"},{\"expression\":\"Article [0-9]+\"}]}],\"groupRules\":[{\"levels\":[{\"expression\":\"^#[^#]\"},{\"expression\":\"^##[^#]\"},{\"expression\":\"^###[^#]\"},{\"expression\":\"^####[^#]\"}]},{\"levels\":[{\"expression\":\"第[零一二三四五六七八九十百0-9]+(分?编|部分)\"},{\"expression\":\"第[零一二三四五六七八九十百0-9]+章\"},{\"expression\":\"第[零一二三四五六七八九十百0-9]+节\"},{\"expression\":\"第[零一二三四五六七八九十百0-9]+条\"},{\"expression\":\"[\\\\((][零一二三四五六七八九十百]+[\\\\))]\"}]},{\"levels\":[{\"expression\":\"第[0-9]+章\"},{\"expression\":\"第[0-9]+节\"},{\"expression\":\"[0-9]{1,2}[\\\\. 、]\"},{\"expression\":\"[0-9]{1,2}\\\\.[0-9]{1,2}($|[^a-zA-Z/%~.-])\"},{\"expression\":\"[0-9]{1,2}\\\\.[0-9]{1,2}\\\\.[0-9]{1,2}\"}]},{\"levels\":[{\"expression\":\"第[零一二三四五六七八九十百0-9]+章\"},{\"expression\":\"第[零一二三四五六七八九十百0-9]+节\"},{\"expression\":\"[零一二三四五六七八九十百]+[ 、]\"},{\"expression\":\"[\\\\((][零一二三四五六七八九十百]+[\\\\))]\"},{\"expression\":\"[\\\\((][0-9]{,2}[\\\\))]\"}]},{\"levels\":[{\"expression\":\"PART (ONE|TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT|NINE|TEN)\"},{\"expression\":\"Chapter (I+V?|VI*|XI|IX|X)\"},{\"expression\":\"Section [0-9]+\"},{\"expression\":\"Article [0-9]+\"}]}],\"hierarchyHierarchy\":\"0\",\"hierarchyGroup\":\"0\",\"method\":\"group\"},\"Tokenizer:GreatCarsWash\":{\"fields\":\"text\",\"filename_embd_weight\":0.1,\"search_method\":[\"embedding\",\"full_text\"]},\"Extractor:AutoExtractDefault\":{\"llm_id\":\"\",\"keywords\":{\"top_n\":0},\"questions\":{\"top_n\":0},\"tags\":{\"top_n\":0,\"tag_file_id\":\"\"},\"summary\":{\"enabled\":false},\"metadata\":{\"enabled\":false,\"metadata\":[],\"built_in_metadata\":[]}}}",
"picture": "{\"File\": {}, \"Parser:ViewsCaptureLight\": {\"enable_vision_enhancement\": false, \"vlm\": {\"llm_id\": \"\"}, \"image\": {\"ocr_enabled\": true, \"preprocess\": [\"main_content\"], \"suffix\": [\"bmp\", \"gif\", \"jpeg\", \"jpg\", \"png\", \"svg\", \"tif\", \"tiff\", \"webp\"]}, \"video\": {\"preprocess\": [\"main_content\"], \"suffix\": [\"3gp\", \"3gpp\", \"avi\", \"flv\", \"mkv\", \"mov\", \"mp4\", \"mpeg\", \"mpg\", \"webm\", \"wmv\"]}}, \"OneChunker:BrightColorsGlow\": {}, \"Tokenizer:SharpLensFocus\": {\"fields\": \"text\", \"filename_embd_weight\": 0.1, \"search_method\": [\"embedding\", \"full_text\"]}, \"Extractor:AutoExtractDefault\": {\"llm_id\": \"\", \"keywords\": {\"top_n\": 0}, \"questions\": {\"top_n\": 0}, \"tags\": {\"top_n\": 0, \"tag_file_id\": \"\"}, \"summary\": {\"enabled\": false}, \"metadata\": {\"enabled\": false, \"metadata\": [], \"built_in_metadata\": []}}}",
- "presentation": "{\"File\": {}, \"Parser:HipSignsRhyme\": {\"enable_vision_enhancement\": false, \"vlm\": {\"llm_id\": \"\"}, \"pdf\": {\"flatten_media_to_text\": false, \"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"pdf\"], \"vlm\": {}}, \"slides\": {\"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"pptx\", \"ppt\"]}}, \"Tokenizer:TallTreesDance\": {\"fields\": \"text\", \"filename_embd_weight\": 0.1, \"search_method\": [\"embedding\", \"full_text\"]}, \"PageChunker:HappyHillsGlow\": {}, \"Extractor:AutoExtractDefault\": {\"llm_id\": \"\", \"keywords\": {\"top_n\": 0}, \"questions\": {\"top_n\": 0}, \"tags\": {\"top_n\": 0, \"tag_file_id\": \"\"}, \"summary\": {\"enabled\": false}, \"metadata\": {\"enabled\": false, \"metadata\": [], \"built_in_metadata\": []}}}",
+ "presentation": "{\"File\": {}, \"Parser:HipSignsRhyme\": {\"enable_vision_enhancement\": false, \"vlm\": {\"llm_id\": \"\"}, \"pdf\": {\"flatten_media_to_text\": false, \"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"pdf\"], \"vlm\": {}}, \"slides\": {\"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"pptx\", \"ppt\", \"dps\", \"dpt\"]}}, \"Tokenizer:TallTreesDance\": {\"fields\": \"text\", \"filename_embd_weight\": 0.1, \"search_method\": [\"embedding\", \"full_text\"]}, \"PageChunker:HappyHillsGlow\": {}, \"Extractor:AutoExtractDefault\": {\"llm_id\": \"\", \"keywords\": {\"top_n\": 0}, \"questions\": {\"top_n\": 0}, \"tags\": {\"top_n\": 0, \"tag_file_id\": \"\"}, \"summary\": {\"enabled\": false}, \"metadata\": {\"enabled\": false, \"metadata\": [], \"built_in_metadata\": []}}}",
"qa": "{\"File\": {}, \"Parser:HipSignsRhyme\": {\"enable_vision_enhancement\": false, \"vlm\": {\"llm_id\": \"\"}, \"docx\": {\"flatten_media_to_text\": false, \"preprocess\": [\"main_content\"], \"suffix\": [\"docx\"], \"vlm\": {}}, \"markdown\": {\"flatten_media_to_text\": false, \"preprocess\": [\"main_content\"], \"suffix\": [\"md\", \"markdown\", \"mdx\"], \"vlm\": {}}, \"pdf\": {\"flatten_media_to_text\": false, \"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"pdf\"], \"vlm\": {}}, \"spreadsheet\": {\"flatten_media_to_text\": false, \"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"xls\", \"xlsx\", \"csv\"], \"vlm\": {}}, \"text&code\": {\"preprocess\": [\"main_content\"], \"suffix\": [\"txt\"]}}, \"Tokenizer:ColdCloudsDream\": {\"fields\": \"text\", \"filename_embd_weight\": 0.1, \"search_method\": [\"embedding\", \"full_text\"]}, \"QAChunker:TidyCloudsThink\": {}}",
"table": "{\"File\": {}, \"Parser:HipSignsRhyme\": {\"enable_vision_enhancement\": false, \"vlm\": {\"llm_id\": \"\"}, \"spreadsheet\": {\"flatten_media_to_text\": false, \"parse_method\": \"DeepDOC\", \"preprocess\": [\"main_content\"], \"suffix\": [\"xls\", \"xlsx\", \"csv\"], \"vlm\": {}, \"column_mode\": \"auto\", \"column_roles\": {}, \"column_names\": []}, \"text&code\": {\"preprocess\": [\"main_content\"], \"suffix\": [\"txt\"]}}, \"TableChunker:FastFoxesJump\": {}, \"Tokenizer:DeepLakesShine\": {\"fields\": \"text\", \"filename_embd_weight\": 0.1, \"search_method\": [\"embedding\", \"full_text\"]}}",
}
diff --git a/internal/service/document/document_dataset_update.go b/internal/service/document/document_dataset_update.go
index 9108159423..6bf1e561bf 100644
--- a/internal/service/document/document_dataset_update.go
+++ b/internal/service/document/document_dataset_update.go
@@ -425,7 +425,7 @@ func isPresentationFile(name *string) bool {
return false
}
ext := strings.ToLower(filepath.Ext(*name))
- return ext == ".ppt" || ext == ".pptx" || ext == ".pages"
+ return ext == ".ppt" || ext == ".pptx" || ext == ".pages" || ext == ".dps" || ext == ".dpt"
}
func validateMetaFields(meta map[string]any) error {
diff --git a/internal/service/document/document_dataset_update_test.go b/internal/service/document/document_dataset_update_test.go
new file mode 100644
index 0000000000..58aaeff25d
--- /dev/null
+++ b/internal/service/document/document_dataset_update_test.go
@@ -0,0 +1,36 @@
+package document
+
+import "testing"
+
+// TestIsPresentationFile pins the name-based presentation guard used by the
+// parser_id / chunk_method switch in document_dataset_update.go. A WPS
+// presentation (dps/dpt) must be treated as a presentation on a par with ppt/
+// pptx/pages, so the API allows switching its chunk_method to "presentation".
+func TestIsPresentationFile(t *testing.T) {
+ p := func(s string) *string { return &s }
+
+ cases := []struct {
+ name string
+ in *string
+ want bool
+ }{
+ {"nil name is not presentation", nil, false},
+ {"ppt is presentation", p("deck.ppt"), true},
+ {"pptx is presentation", p("deck.pptx"), true},
+ {"pages is presentation", p("deck.pages"), true},
+ {"wps presentation dps is presentation", p("deck.dps"), true},
+ {"wps presentation dpt is presentation", p("deck.dpt"), true},
+ {"wps presentation dps is case-insensitive", p("DECK.DPS"), true},
+ {"pdf is not presentation", p("report.pdf"), false},
+ {"wps doc is not presentation", p("note.wps"), false},
+ {"wps sheet et is not presentation", p("sheet.et"), false},
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := isPresentationFile(tc.in); got != tc.want {
+ t.Fatalf("isPresentationFile(%v) = %v, want %v", tc.in, got, tc.want)
+ }
+ })
+ }
+}
diff --git a/internal/service/document/document_parser_selection.go b/internal/service/document/document_parser_selection.go
index 00ffe02fee..435199233c 100644
--- a/internal/service/document/document_parser_selection.go
+++ b/internal/service/document/document_parser_selection.go
@@ -42,7 +42,9 @@ func dedicatedDocumentParserID(filetype utility.FileType, filename string) strin
switch {
case strings.HasSuffix(name, ".ppt"),
strings.HasSuffix(name, ".pptx"),
- strings.HasSuffix(name, ".pages"):
+ strings.HasSuffix(name, ".pages"),
+ strings.HasSuffix(name, ".dps"),
+ strings.HasSuffix(name, ".dpt"):
return "presentation"
case strings.HasSuffix(name, ".msg"),
strings.HasSuffix(name, ".eml"):
diff --git a/internal/service/document/document_parser_selection_test.go b/internal/service/document/document_parser_selection_test.go
index ba1d48c22d..4721f284d8 100644
--- a/internal/service/document/document_parser_selection_test.go
+++ b/internal/service/document/document_parser_selection_test.go
@@ -27,6 +27,9 @@ func TestDedicatedDocumentParserID(t *testing.T) {
{"pptx routes to presentation", utility.FileTypeDOC, "deck.pptx", "presentation"},
{"legacy ppt routes to presentation", utility.FileTypeDOC, "deck.ppt", "presentation"},
{"pages routes to presentation", utility.FileTypeDOC, "deck.pages", "presentation"},
+ {"wps presentation dps routes to presentation", utility.FileTypePPT, "deck.dps", "presentation"},
+ {"wps presentation dpt routes to presentation", utility.FileTypePPT, "deck.dpt", "presentation"},
+ {"wps presentation dps is case-insensitive", utility.FileTypePPT, "DECK.DPS", "presentation"},
{"presentation extension is case-insensitive", utility.FileTypeDOC, "DECK.PPTX", "presentation"},
{"eml routes to email", utility.FileTypeDOC, "mail.eml", "email"},
{"msg routes to email", utility.FileTypeDOC, "mail.msg", "email"},
@@ -337,6 +340,15 @@ func TestResolveDocumentParser_Priority(t *testing.T) {
wantParserID: "presentation",
wantFamilyIn: "slides",
},
+ {
+ name: "wps presentation dps reaches its owner pipeline",
+ kbParser: "general",
+ kbConfig: generalParserConfig(),
+ filename: "deck.dps",
+ filetype: utility.FileTypePPT,
+ wantParserID: "presentation",
+ wantFamilyIn: "slides",
+ },
{
name: "an unmappable visual extension still reaches picture",
kbParser: "general",
diff --git a/internal/utility/file.go b/internal/utility/file.go
index 7d22d62ae4..b83a380272 100644
--- a/internal/utility/file.go
+++ b/internal/utility/file.go
@@ -84,17 +84,17 @@ func GetFileType(filename string) FileType {
switch suffix {
case "pdf":
return FileTypePDF
- case "xls":
+ case "xls", "et", "ett":
return FileTypeXLS
case "xlsx":
return FileTypeXLSX
case "csv":
return FileTypeCSV
- case "doc":
+ case "doc", "wps", "wpt":
return FileTypeDOC
case "docx":
return FileTypeDOCX
- case "ppt":
+ case "ppt", "dps", "dpt":
return FileTypePPT
case "pptx":
return FileTypePPTX
@@ -143,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",
+ "csv", "txt", "ini", "xls", "xlsx", "wps", "wpt", "et", "ett", "dps", "dpt", "rtf", "hlp", "pages", "numbers", "key",
"md", "markdown", "mdx", "py", "js", "java", "c", "cpp", "h", "php", "go", "ts", "sh", "cs", "kt",
"html", "sql", "epub",
}
diff --git a/internal/utility/wps_filetype_test.go b/internal/utility/wps_filetype_test.go
new file mode 100644
index 0000000000..008f2c6382
--- /dev/null
+++ b/internal/utility/wps_filetype_test.go
@@ -0,0 +1,120 @@
+//
+// 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"
+
+// wpsRoutes maps a WPS private-format extension (without dot) to the MS-Office
+// FileType it must resolve to. WPS reuses the legacy MS-OLE2/CFB binary
+// structure, so .wps/.wpt are Word-compatible (DOC), .et/.ett are
+// Excel-compatible (XLS), and .dps/.dpt are PowerPoint-compatible (PPT).
+var wpsRoutes = []struct {
+ ext string
+ want FileType
+}{
+ {"wps", FileTypeDOC},
+ {"wpt", FileTypeDOC},
+ {"et", FileTypeXLS},
+ {"ett", FileTypeXLS},
+ {"dps", FileTypePPT},
+ {"dpt", FileTypePPT},
+}
+
+// TestGetFileType_WPS_ExactRouting verifies the precise parser-family routing
+// for every WPS private extension. This is the gate that actually feeds
+// parser.GetParser, so a wrong mapping silently drops the file to text mode.
+func TestGetFileType_WPS_ExactRouting(t *testing.T) {
+ for _, r := range wpsRoutes {
+ t.Run(r.ext, func(t *testing.T) {
+ got := GetFileType("sample." + r.ext)
+ if got != r.want {
+ t.Errorf("GetFileType(%q) = %q, want %q", "sample."+r.ext, got, r.want)
+ }
+ })
+ }
+}
+
+// TestGetFileType_WPS_CaseInsensitiveAndPath ensures case folding and a
+// leading directory do not defeat the match (mirrors how real uploads arrive).
+func TestGetFileType_WPS_CaseInsensitiveAndPath(t *testing.T) {
+ cases := []struct {
+ name string
+ filename string
+ want FileType
+ }{
+ {"uppercase", "SLIDE.DPT", FileTypePPT},
+ {"mixed case", "Book.Et", FileTypeXLS},
+ {"leading dir", "/data/reports/quarter.wps", FileTypeDOC},
+ {"nested dir", "a/b/c/template.ett", FileTypeXLS},
+ {"long path mixed case", "/X/Y/Z/DECK.Dps", FileTypePPT},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ got := GetFileType(tc.filename)
+ if got != tc.want {
+ t.Errorf("GetFileType(%q) = %q, want %q", tc.filename, got, tc.want)
+ }
+ })
+ }
+}
+
+// TestGetFileType_WPS_NoOverMatch guards against accidentally widening the
+// match: a non-WPS suffix that merely contains a WPS substring (or a doubled
+// extension) must stay OTHER.
+func TestGetFileType_WPS_NoOverMatch(t *testing.T) {
+ cases := []string{
+ "notes.wpsx", // not .wps
+ "data.etx", // not .et
+ "saved.dpts", // not .dpt
+ "contract.wps.bak",
+ "slide.dpt.tmp",
+ }
+ for _, name := range cases {
+ t.Run(name, func(t *testing.T) {
+ if got := GetFileType(name); got != FileTypeOTHER {
+ t.Errorf("GetFileType(%q) = %q, want %q (must not over-match)", name, got, FileTypeOTHER)
+ }
+ })
+ }
+}
+
+// TestFilenameType_WPS_Accepted verifies the upload gate (FilenameType) no
+// longer rejects WPS private formats with FileTypeOTHER. FilenameType buckets
+// all office documents as FileTypeDOC, consistent with how .ppt/.doc/.xls are
+// already handled; the precise family is re-derived downstream by GetFileType.
+func TestFilenameType_WPS_Accepted(t *testing.T) {
+ for _, r := range wpsRoutes {
+ t.Run(r.ext, func(t *testing.T) {
+ got := FilenameType("sample." + r.ext)
+ if got == FileTypeOTHER {
+ t.Errorf("FilenameType(%q) = %q, want non-OTHER (upload gate must accept)", "sample."+r.ext, got)
+ }
+ })
+ }
+}
+
+// TestFilenameType_WPS_DoesNotLoosenGate ensures the new extensions did not
+// weaken the gate: a genuinely unknown extension is still rejected.
+func TestFilenameType_WPS_DoesNotLoosenGate(t *testing.T) {
+ for _, name := range []string{"mystery.xyz", "noext", "weird.wpsx"} {
+ t.Run(name, func(t *testing.T) {
+ if got := FilenameType(name); got != FileTypeOTHER {
+ t.Errorf("FilenameType(%q) = %q, want %q (gate must stay strict)", name, got, FileTypeOTHER)
+ }
+ })
+ }
+}