Skip to content

Commit

Permalink
fix(tauri/asset): escape octal sequences in css (#1166)
Browse files Browse the repository at this point in the history
* fix(tauri/asset): escape octal sequences in css

* chore(package): add .changes file
  • Loading branch information
nklayman committed Jan 30, 2021
1 parent 4c8634d commit 4491c70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/css-inliner-octal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Replace `\` with `\\` in css assets that are lazy loaded. Since these are injected in a template literal, backslashes must be escaped. Backslashes are sometimes used for octal sequences in CSS.
3 changes: 2 additions & 1 deletion tauri/src/endpoints/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ pub fn load(
document.getElementsByTagName("head")[0].appendChild(css);
}})(`{css}`)
"#,
css = asset_str
// Escape octal sequences, which aren't allowed in template literals
css = asset_str.replace("\\", "\\\\").as_str()
));
} else {
webview_ref.eval(asset_str);
Expand Down

0 comments on commit 4491c70

Please sign in to comment.