Skip to content

Commit

Permalink
fix: decode html entities before rendering
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
harlan-zw committed Feb 26, 2023
1 parent ebf2594 commit dbea3a4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/runtime/nitro/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ export function base64ToArrayBuffer(base64: string): ArrayBuffer {
}

export function renderIsland(payload: OgImageOptions) {
// for the payload, we unencode any html
Object.entries(payload).forEach(([key, value]) => {
// unescape all html tokens
if (typeof value === 'string') {
payload[key] = value
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&amp;/g, '&')
.replace(/&quot;/g, '"')
.replace(/&#x27;/g, '\'')
.replace(/&#x2F;/g, '/')
}
})
return globalThis.$fetch<{ html: string; head: any }>(`/__nuxt_island/${payload.component}`, {
query: { props: JSON.stringify(payload) },
})
Expand Down

0 comments on commit dbea3a4

Please sign in to comment.