Repository navigation
fix(preview): play local files in raw HTML video and audio players - #1081
Merged
Merged
Conversation
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.
A raw HTML player pointing at a file next to the document showed its controls but never loaded:
Found and first fixed by @August-At-Play in #1075. This keeps that fix's two parts and leaves out the rest, so the image path does not change.
Mechanism
processBlockMarkupresolved local<img>sources against the document, but notvideo[src],audio[src]or their<source>children, so those resolved against the webview.media-src, so media fell back todefault-src 'self', which refuses Windows'http://asset.localhost.The image code is now
localSrc, unchanged, and the media elements go through it too, before the images, whose media links () become players with a src already converted.media-srcallows the same two asset spellingsimg-srcdoes.Scope
file:URLs. Images do not take them either. Paths are written relative to the document or absolute, as for images.Tests
preview.localMedia.test.tsrunsprocessMarkdownHtmlover a direct src, a nested<source>and a media link written as an image. The first goes red without the fix, the last goes red if the two loops swap order. A config test pinsmedia-src, and goes red without it.Verification
npm run check,npm run lint,npm test(958 passed),npx vitest run(770 passed),vite buildandcheck-startup-chunk,cargo fmt --check,cargo test --locked(249 passed), bindings unchanged.<source>with a space in the file name, and an image-syntax link all played.