fix: keep local images through folder import and allow remote markdown images - #697
Open
chang30519-art wants to merge 1 commit into
Open
fix: keep local images through folder import and allow remote markdown images#697chang30519-art wants to merge 1 commit into
chang30519-art wants to merge 1 commit into
Conversation
…n images Folder imports dropped every image file because the default source-watch includeExtensions whitelist only contained document formats. An imported .md therefore referenced sibling images that were never copied into raw/sources, so both the source preview and the ingest-time extractAndSaveMarkdownImages lookup failed silently. Add the extensions already accepted by findLocalMarkdownImageRefs (png/jpg/jpeg/gif/webp/bmp/tif/tiff/svg) to the default whitelist. Image files are resource-only: isIngestableSourcePath still keeps them out of the ingest queue. Also relax img-src in the Tauri CSP to include https:/http:. The markdown image resolver passes remote URLs through unchanged, but the webview CSP blocked every <img src=https://...>, so web-embedded images never rendered in previews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small fixes for markdown image handling found while importing a folder of
.mdnotes with local images:1. Folder import dropped every local image file
importSourceFolderfilters every file throughisPathAllowedBySourceWatch, and the defaultincludeExtensionswhitelist (source-watch-defaults.json) only contains document formats — no image extensions at all. After a folder import:.mdfiles land inraw/sources/<folder>/...excludedConsequences:
resolve (Obsidian-style, viaresolveMarkdownImageSrc) to<project>/raw/sources/<folder>/images/a.png, which was never copied.extractAndSaveMarkdownImagesresolves refs against the same missing paths (fileExists→ skip), so there are never any images to hand to the vision-caption pipeline.This adds the exact extensions already accepted by
findLocalMarkdownImageRefs(png/jpg/jpeg/gif/webp/bmp/tif/tiff/svg) to the default whitelist. Image files stay resource-only —isIngestableSourcePathstill keeps them out of the ingest queue.2. CSP blocked remote markdown images
The resolver passes
http(s)://image URLs through unchanged, but the Tauri CSP only allowedimg-src 'self' asset: blob: data:— so every web-embedded image () was refused by the webview and rendered as broken. (connect-srcalready allowedhttps: http:, which is why everything else worked.)Adds
https: http:toimg-src. This matches what Obsidian/Typora-style markdown editors do; local file access remains restricted by'self'+ the asset protocol scope.Testing
vitest run src/lib/source-watch-config.test.ts src/lib/source-lifecycle.test.ts src/lib/extract-source-images.test.ts— 28 passedvitest run src/lib/project-file-sync.test.ts src/lib/scheduled-import.test.ts src/lib/ingest-queue.test.ts src/components/sources/sources-view.test.ts— 108 passedManual verification of the CSP change requires a rebuild (
npm run tauri build).