Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/breezy-plums-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a case where the error overlay would not escape the message
2 changes: 1 addition & 1 deletion packages/astro/e2e/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test.describe('Error display', () => {
await page.goto(astro.resolveUrl('/astro-syntax-error'), { waitUntil: 'networkidle' });

const message = (await getErrorOverlayContent(page)).message;
expect(message).toMatch('Unexpected "while"');
expect(message).toMatch('Unexpected "while"');

await Promise.all([
// Wait for page reload
Expand Down
5 changes: 4 additions & 1 deletion packages/astro/src/core/errors/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,10 @@ class ErrorOverlay extends HTMLElement {

this.text('#name', err.name);
this.text('#title', err.title);
this.text('#message-content', err.message, true);
// Only set as html if escaped. We're only sure it's escaped if name is part
// of the error, ie. we transformed it as we wanted.
// TODO: capture error at the source and transform it there
this.text('#message-content', err.message, 'name' in err);

const cause = this.root.querySelector<HTMLElement>('#cause');
if (cause && err.cause) {
Expand Down
Loading