From c2b2e4b2b291755d0af2b1705d1f96dcbbf6bd1a Mon Sep 17 00:00:00 2001 From: David Iglesias Date: Tue, 16 Jan 2024 14:53:08 -0800 Subject: [PATCH] [web] Leave blob URLs untouched in TT policy. (flutter/engine#49782) Very simple tweak to flutter.js that allows blob URLs to be used as entrypointUrls when loading flutter (this is needed by dartpad) ## Testing I had to test this locally by spinning up a flutter app with something like: ```html ``` ## Issues * Fixes https://github.com/flutter/flutter/issues/141329 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../src/flutter/lib/web_ui/flutter_js/src/trusted_types.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engine/src/flutter/lib/web_ui/flutter_js/src/trusted_types.js b/engine/src/flutter/lib/web_ui/flutter_js/src/trusted_types.js index 76db604dba..eeeef9a1ba 100644 --- a/engine/src/flutter/lib/web_ui/flutter_js/src/trusted_types.js +++ b/engine/src/flutter/lib/web_ui/flutter_js/src/trusted_types.js @@ -20,6 +20,11 @@ export class FlutterTrustedTypesPolicy { if (window.trustedTypes) { this.policy = trustedTypes.createPolicy(policyName, { createScriptURL: function (url) { + // Return blob urls without manipulating them + if (url.startsWith('blob:')) { + return url; + } + // Validate other urls const parsed = new URL(url, window.location); const file = parsed.pathname.split("/").pop(); const matches = patterns.some((pattern) => pattern.test(file));