We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb87222 commit 3b21e64Copy full SHA for 3b21e64
api/src/functions/contact-form.ts
@@ -1,3 +1,4 @@
1
+import * as _ from 'lodash';
2
import nodemailer from 'nodemailer';
3
import * as log from 'loglevel';
4
import { delay } from '@httptoolkit/util';
@@ -90,7 +91,14 @@ export const handler = catchErrors(async (event) => {
90
91
html: `<html><style>p { margin-bottom: 10px; }</style><body>
92
${
93
fields.map(([field, value]) => {
- return `<p><strong>${field}</strong>:<br/>${value}</p>`;
94
+ return `<p><strong>${field}</strong>:<br/>${
95
+ // Escape any HTML in inputs and preserve newlines:
96
+ field === 'Message'
97
+ ? _.escape(value)
98
+ .replace(/\n/g, '<br>')
99
+ .replace(/ /g, ' ')
100
+ : _.escape(value)
101
+ }</p>`;
102
}).join('')
103
}</body></html>`
104
});
0 commit comments