Skip to content

Commit e8cf4d6

Browse files
tomischrothbn
authored andcommitted
fix(core): Fix html header check (#22713)
1 parent e3f2bef commit e8cf4d6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/core/src/__tests__/html-sandbox.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,15 @@ describe('isHtmlRenderedContentType', () => {
7575
});
7676
});
7777

78+
it('should handle content type with extra spaces', () => {
79+
expect(isHtmlRenderedContentType(' text/html')).toBe(true);
80+
expect(isHtmlRenderedContentType('text/html ')).toBe(true);
81+
expect(isHtmlRenderedContentType(' text/html ')).toBe(true);
82+
});
83+
7884
it('should handle edge cases', () => {
7985
expect(isHtmlRenderedContentType('text/htmlsomething')).toBe(true);
8086
expect(isHtmlRenderedContentType('application/xhtml+xmlsomething')).toBe(true);
81-
expect(isHtmlRenderedContentType(' text/html')).toBe(false);
82-
expect(isHtmlRenderedContentType('text/html ')).toBe(true);
8387
});
8488
});
8589

packages/core/src/html-sandbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const getWebhookSandboxCSP = (): string => {
1717
* as HTML.
1818
*/
1919
export const isHtmlRenderedContentType = (contentType: string) => {
20-
const contentTypeLower = contentType.toLowerCase();
20+
const contentTypeLower = contentType.trim().toLowerCase();
2121

2222
return (
2323
// The content-type can also contain a charset, e.g. "text/html; charset=utf-8"

0 commit comments

Comments
 (0)