{"record":{"id":"daa77e9f28af029e","repo":"siyuan-note/siyuan","slug":"unsupported-rich-clipboard-image-extension-s","errorCode":null,"errorMessage":"unsupported rich clipboard image extension [%s]","messagePattern":"unsupported rich clipboard image extension \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/clipboard.go","lineNumber":88,"sourceCode":"\n\tbatch := util.RandString(24)\n\tgroups := map[string]struct{}{}\n\tcopied := map[string]string{}\n\tret = &RichClipboardPrepared{Batch: batch}\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tcleanupRichClipboardGroups(batch, groups)\n\t\t}\n\t}()\n\n\tfor _, asset := range assets {\n\t\tif asset.Index < 0 {\n\t\t\treturn nil, fmt.Errorf(\"invalid rich clipboard asset index [%d]\", asset.Index)\n\t\t}\n\n\t\text := strings.ToLower(filepath.Ext(AssetPathWithoutQuery(asset.Path)))\n\t\tif _, ok := richClipboardImageExts[ext]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"unsupported rich clipboard image extension [%s]\", ext)\n\t\t}\n\n\t\tabsPath, resolveErr := GetAssetAbsPathInBox(asset.Path, asset.Box)\n\t\tif resolveErr != nil {\n\t\t\treturn nil, resolveErr\n\t\t}\n\n\t\tdestPath, ok := copied[absPath]\n\t\tif !ok {\n\t\t\tgroup := ExtractBoxIDFromAssetsPath(absPath)\n\t\t\tif group == \"\" {\n\t\t\t\tgroup = richClipboardGlobalGroup\n\t\t\t}\n\t\t\tgroups[group] = struct{}{}\n\n\t\t\tdestDir := filepath.Join(util.TempDir, \"clipboard\", group, batch)\n\t\t\tif mkdirErr := os.MkdirAll(destDir, 0700); mkdirErr != nil {\n\t\t\t\treturn nil, mkdirErr","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/clipboard.go#L70-L106","documentation":"Returned by PrepareRichClipboardAssets when the file extension of an asset path is not in the richClipboardImageExts allow-list. The extension is extracted via filepath.Ext after lowercasing and after stripping any query string via AssetPathWithoutQuery. Only image types registered in that map are accepted for rich clipboard copying.","triggerScenarios":"An asset path points to a non-image file (e.g. .pdf, .docx) or an image format not in the allow-list (e.g. a less common format), or the path has no extension at all. The check runs per asset after the index validation.","commonSituations":"Paste handler collected a file reference that is not an image; user copied content containing an embedded SVG or HEIC that is not whitelisted; asset URL carries a query string that, even after stripping, leaves an unsupported extension.","solutions":["Filter the assets array on the frontend to only include image extensions the server supports (PNG, JPG, GIF, etc.) before calling.","If you need a format that is rejected, add it to the richClipboardImageExts map (kernel change) or convert the asset to a supported format.","Confirm AssetPathWithoutQuery is applied client-side too so query strings do not corrupt extension detection."],"exampleFix":"// before: send everything\nassets = append(assets, RichClipboardAsset{Path: anyPath})\n\n// after: filter to supported image extensions\nvar allowed = map[string]bool{\".png\": true, \".jpg\": true, \".jpeg\": true, \".gif\": true, \".webp\": true}\nfor _, p := range paths {\n    ext := strings.ToLower(filepath.Ext(p))\n    if allowed[ext] {\n        assets = append(assets, RichClipboardAsset{Path: p})\n    }\n}","handlingStrategy":"validation","validationCode":"var richClipboardImageExts = map[string]bool{\".png\":true,\".jpg\":true,\".jpeg\":true,\".gif\":true,\".webp\":true,\".bmp\":true,\".svg\":true}\nfunc supportedImageExt(path string) bool {\n    ext := strings.ToLower(filepath.Ext(stripQuery(path)))\n    return richClipboardImageExts[ext]\n}","typeGuard":"func isSupportedImage(path string) bool { return supportedImageExt(path) }","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unsupported rich clipboard image extension\") { filterToImagesAndRetry() }","preventionTips":["Mirror the server's allow-list on the client and filter before sending.","Convert unsupported formats to PNG/JPG before clipboard preparation.","Strip query strings before extracting extensions."],"tags":["clipboard","assets","validation","file-extension","images"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}