Add embed:// scheme for serving trusted local content - #34
Merged
Conversation
callumlinden
approved these changes
Jul 24, 2026
callumlinden
left a comment
Contributor
There was a problem hiding this comment.
Looks great - nice work. Just a couple of minor comments:
-
I see references to the scheme name and format in many places, in different files. E.G.
const char* kEmbedScheme = "embed"; const char* kEmbedSchemePrefix = "embed://"; -
Would it be worth centralizing that in a header perhaps so that it only needs to be changed once?
-
See a lot of places where the lowercase version of a string is created. Is that okay for non-ascii strings (I think it is - just checking) and worth using a single 'canonical' ToLower() function like:
std::string text = "HeLLo WoRLd!"; auto lower_text = text | std::views::transform([](unsigned char c) { return std::tolower(c); }) | std::ranges::to<std::string>(); // Converts view back to std::string std::cout << lower_text; // outputs: hello world! -
Might need to add entries in the mime_for_path() function for other file types in Garfield's 3p package - E.G. TypeScript
.ts
Contributor
Author
|
Thanks, it makes sense. |
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.
Added a new custom
embed://scheme served entirely by Dullahan from an on-disk root that the Viewer configures. Content is treated by CEF as a proper secure origin.Registry allowlist. The host configures a registry of allowed paths. Exact-match paths are supported for individual files; entries ending in / are treated as directory prefixes. Any request that doesn't match returns 404 without touching disk.
Related Viewer-side API:
setEmbedSchemeRoot(root_dir)andsetEmbedRegistry(allowed_paths)to configure the scheme handler.Bridge scoping. The
window.JSONtoCPPJS bridge is now injected only on frames whose URL is underembed://. Ordinary web pages don't see the bridge. Each JS→C++ message also carries the calling frame's URL so the host can verify origin.Recursive-inheritance enforcement. A browser whose top-level document is an
embed://page may only loadembed://ordata:sub-resources - no external iframes, images, scripts, stylesheets, fetches, or beacons. Conversely, a browser NOT runningembed://content cannot fetchembed://resources. Applied viaOnBeforeResourceLoad; enforced by tracking the trust context set inOnBeforeBrowseto avoid a UI/IO thread race that would otherwise misclassify sub-resources fired right after a navigation commits.Navigation lockdown. Top-level navigation into
embed://from a user-clicked link or an HTTP redirect is rejected. Loadingembed://requires an explicit LoadURL call from the host.