Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
feat(edusharing-asset): Render content where no type could be determi…
Browse files Browse the repository at this point in the history
…ned in iframe

Using an iframe as a backup might be safer compared to `dangerouslySetInnerHtml` because <script> tags will get executed.
  • Loading branch information
LarsTheGlidingSquirrel committed Mar 20, 2024
1 parent 970912d commit ec9763d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/frontend/plugins/edusharing-asset/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,13 @@ export function EdusharingAssetRenderer(props: {
}
}

// If the detailsSnipped was not handled by one of the handlers above, change nothing in html snippet
// Backup when content type could not be determined above -> Render in iframe with iframe-resizer.
// This will make sure <script> tags execute. They would not if using 'dangerously-set-inner-html'
return {
html: detailsSnippet,
renderMethod: 'dangerously-set-inner-html',
html:
detailsSnippet +
'<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"></script>',
renderMethod: 'iframe',
defineContainerHeight: false,
}
}
Expand Down

0 comments on commit ec9763d

Please sign in to comment.