-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latest version requires unsafe-inline due to inline styles #4445
Comments
It always needed it depending on the renderer you are using. Is the proposal that the nonce is generated by the server and passed into xterm.js as an option? |
Same issue here, properties like font-family are blocked by CSP in newest version 5.2.1. I would be fine if I can pass a server-generated nonce to the Terminal constructor. Kind regards, |
What would be the best way forward here? As I have lit. no clue about CSP scoping rules, some help from more experienced CSP-focused devs would be appreciated.
|
Well one option would be to use stylesheets instead of inline styles, which is the reason it became a problem in the first place. |
Thats not possible for all styling parts, as some are calculated from metrics in JS. |
You could consider updating css variables via |
The only thing that CSP is blocking if you use inline |
This is not an option as styling every single character like this would hurt performance.
This sounds fine, let's add a |
Maybe the const sheet = new CSSStyleSheet();
sheet.replaceSync("a { color: red; }");
document.adoptedStyleSheets.push(sheet) |
@SimonSiefke if that works around the CSP issue we could use that method in the browsers that support it 👍 |
This change was reverted in #4680 |
A workaround until CSPs are implemented again: use the webgl addon! I was getting CSP errors when importing xtermjs in my angular app, and had only a non functional black box. By using the webgl backend I am still getting CSP errors, but now I have a functional xtermjs! |
Content Security Policies need to be set to 'unsafe-inline' to work with xterm.js. Older versions didn't use inline styles so this wasn't an issue.
Ideally xterm should stop using inline styles or support a user-provided nonce value that can be set in the CSP. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src
Details
Steps to reproduce
The text was updated successfully, but these errors were encountered: