From b96b1fb6b8a4f565fb946847bb9a29d9d939e2cb Mon Sep 17 00:00:00 2001 From: chip Date: Sat, 25 Jul 2020 11:52:52 -0700 Subject: [PATCH] inject css with template string to allow for line breaks (#894) * inject css with template string to allow for line breaks alternative solution would to be implement a struct `JsStringLiteral` with `fmt::Display` that escapes all forbidden codepoints from the spec https://www.ecma-international.org/ecma-262/#sec-literals-string-literals template string literal seems fine as all browsers that tauri supports have had support for them for the past 3-4+ years Signed-off-by: Chip Reed * chore(changes) adjust change file Co-authored-by: Lucas Nogueira --- .changes/load-asset-css.md | 2 +- tauri/src/endpoints/asset.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changes/load-asset-css.md b/.changes/load-asset-css.md index 5236ac24a..e5aeaf623 100644 --- a/.changes/load-asset-css.md +++ b/.changes/load-asset-css.md @@ -2,4 +2,4 @@ "tauri": patch --- -make sure css content injected is inside a string and not injected raw +Make sure CSS content loaded with the `loadAsset` API is inside a template string and not injected raw. diff --git a/tauri/src/endpoints/asset.rs b/tauri/src/endpoints/asset.rs index 9f5bb779e..0f30f205d 100644 --- a/tauri/src/endpoints/asset.rs +++ b/tauri/src/endpoints/asset.rs @@ -73,7 +73,7 @@ pub fn load( else css.appendChild(document.createTextNode(content)) document.getElementsByTagName("head")[0].appendChild(css); - }})("{css}") + }})(`{css}`) "#, css = asset_str ));