-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
dev: Add email preview tool #10381
dev: Add email preview tool #10381
Conversation
65687f3
to
2034a3a
Compare
2034a3a
to
70c385c
Compare
|
||
const renderResult = renderEmail(templateName); | ||
const attributes = getTemplateAttributes(renderResult.html); | ||
res.send(attributes.body); |
Check warning
Code scanning / CodeQL
Exception text reinterpreted as HTML Medium
Exception text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 2 months ago
To fix the problem, we need to ensure that the attributes.body
is properly sanitized before being sent in the response. This can be achieved by using a library like sanitize-html
to strip any potentially dangerous HTML content from the attributes.body
.
- Import the
sanitize-html
library. - Use the
sanitize-html
function to sanitizeattributes.body
before sending it in the response.
-
Copy modified line R10 -
Copy modified line R186
@@ -9,3 +9,3 @@ | ||
import templates, { isValidTemplate, recompileAllTemplates } from '../../server/lib/emailTemplates'; | ||
import { stripHTML } from '../../server/lib/sanitize-html'; | ||
import { stripHTML, sanitizeHTML } from '../../server/lib/sanitize-html'; | ||
import MOCKS from '../../test/mocks/data'; | ||
@@ -185,3 +185,3 @@ | ||
const attributes = getTemplateAttributes(renderResult.html); | ||
res.send(attributes.body); | ||
res.send(sanitizeHTML(attributes.body)); | ||
} catch (error) { |
fe5dbac
to
f6bad0b
Compare
f6bad0b
to
a48cab1
Compare
A minimalist tool to work on email templates styles and content. Start it with:
List emails
Preview template