From d2ae0b4b6056ac993949fb3d6e676119021a9f62 Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Tue, 19 May 2026 12:13:05 -0500 Subject: [PATCH] Fix SyntaxError in account-dashboard and expand CSP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace ternary operator in native_js block with explicit if-else — El's parser chokes on '?' adjacent to single-quoted strings inside native_js(), causing an Uncaught SyntaxError that prevents the entire IIFE from running and leaves signInWith undefined. Add missing CSP entries to all three header functions: - js.stripe.com → script-src and frame-src (Stripe JS and Elements iframe) - fonts.googleapis.com → style-src (Google Fonts CSS) - fonts.gstatic.com → font-src (Google Fonts files) - static.cloudflareinsights.com → script-src (Cloudflare beacon) --- src/js/account-dashboard.el | 6 +++--- src/main.el | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/js/account-dashboard.el b/src/js/account-dashboard.el index 9d093ce..479037a 100644 --- a/src/js/account-dashboard.el +++ b/src/js/account-dashboard.el @@ -105,9 +105,9 @@ fn main() -> Void { var devicesEl = document.getElementById('devices-count-el'); if (devicesEl) { - devicesEl.textContent = (plan === 'free') - ? '1 device included with your plan' - : '2 devices included with your plan'; + var deviceText = '2 devices included with your plan'; + if (plan === 'free') { deviceText = '1 device included with your plan'; } + devicesEl.textContent = deviceText; } var meta = ''; diff --git a/src/main.el b/src/main.el index 7dc52f9..1d5ede5 100644 --- a/src/main.el +++ b/src/main.el @@ -2317,7 +2317,7 @@ fn sec_headers_json() -> String { + "\"X-Frame-Options\":\"SAMEORIGIN\"," + "\"Referrer-Policy\":\"strict-origin-when-cross-origin\"," + "\"Permissions-Policy\":\"geolocation=(), microphone=(), camera=()\"," - + "\"Content-Security-Policy\":\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://challenges.cloudflare.com https://cdn.jsdelivr.net https://www.googletagmanager.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline'; frame-src https://challenges.cloudflare.com; connect-src 'self' https://api.stripe.com https://*.supabase.co; img-src 'self' data: https:; font-src 'self' data:\"}" + + "\"Content-Security-Policy\":\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://challenges.cloudflare.com https://cdn.jsdelivr.net https://js.stripe.com https://static.cloudflareinsights.com https://www.googletagmanager.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; frame-src https://challenges.cloudflare.com https://js.stripe.com; connect-src 'self' https://api.stripe.com https://*.supabase.co; img-src 'self' data: https:; font-src 'self' data: https://fonts.gstatic.com\"}" } // Headers for compiled JS assets. Explicitly sets Content-Type so the browser @@ -2333,7 +2333,7 @@ fn js_headers_json() -> String { + "\"X-Frame-Options\":\"SAMEORIGIN\"," + "\"Referrer-Policy\":\"strict-origin-when-cross-origin\"," + "\"Permissions-Policy\":\"geolocation=(), microphone=(), camera=()\"," - + "\"Content-Security-Policy\":\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://challenges.cloudflare.com https://cdn.jsdelivr.net https://www.googletagmanager.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline'; frame-src https://challenges.cloudflare.com; connect-src 'self' https://api.stripe.com https://*.supabase.co; img-src 'self' data: https:; font-src 'self' data:\"}" + + "\"Content-Security-Policy\":\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://challenges.cloudflare.com https://cdn.jsdelivr.net https://js.stripe.com https://static.cloudflareinsights.com https://www.googletagmanager.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; frame-src https://challenges.cloudflare.com https://js.stripe.com; connect-src 'self' https://api.stripe.com https://*.supabase.co; img-src 'self' data: https:; font-src 'self' data: https://fonts.gstatic.com\"}" } // Headers for static assets under /assets/ and /brand/. @@ -2349,7 +2349,7 @@ fn static_asset_headers_json() -> String { + "\"X-Frame-Options\":\"SAMEORIGIN\"," + "\"Referrer-Policy\":\"strict-origin-when-cross-origin\"," + "\"Permissions-Policy\":\"geolocation=(), microphone=(), camera=()\"," - + "\"Content-Security-Policy\":\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://challenges.cloudflare.com https://cdn.jsdelivr.net https://www.googletagmanager.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline'; frame-src https://challenges.cloudflare.com; connect-src 'self' https://api.stripe.com https://*.supabase.co; img-src 'self' data: https:; font-src 'self' data:\"}" + + "\"Content-Security-Policy\":\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://challenges.cloudflare.com https://cdn.jsdelivr.net https://js.stripe.com https://static.cloudflareinsights.com https://www.googletagmanager.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; frame-src https://challenges.cloudflare.com https://js.stripe.com; connect-src 'self' https://api.stripe.com https://*.supabase.co; img-src 'self' data: https:; font-src 'self' data: https://fonts.gstatic.com\"}" } fn handle_request(method: String, path: String, headers: Map, body: String) -> String { -- 2.52.0