Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove srcDoc from <iframe/> #262

Merged
merged 1 commit into from
May 2, 2023
Merged
Changes from all 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
33 changes: 1 addition & 32 deletions src/components/ViewPresignedUrl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,7 @@ export default function ViewPresignedUrl({ presingedUrl }: Props) {
}

// Return HTML (via iframe) display

/** **************************** TEMPORARY SOLUTION ****************************
*
* Only allow S3 presigned url that is allowed to be viewed in this <iframe/> tag.
*
* See below 'TEMPORARY SOLUTION' block for details. Change to original solution if the fix has been made.
*
* Current solution: if (HTML_FILETYPE_LIST.includes(filetype) && presingedUrl.startsWith('https://umccr')) {
* Original solution: if (HTML_FILETYPE_LIST.includes(filetype)) {
*
* */
if (HTML_FILETYPE_LIST.includes(filetype) && presingedUrl.startsWith('https://umccr')) {
if (HTML_FILETYPE_LIST.includes(filetype)) {
return (
<div className='w-full h-full'>
<iframe className='w-full h-full bg-white' src={presingedUrl} />
Expand Down Expand Up @@ -109,26 +98,6 @@ export default function ViewPresignedUrl({ presingedUrl }: Props) {
return <CircularLoaderWithText text='Fetching Content' />;
}

/** **************************** TEMPORARY SOLUTION ****************************
*
* This is specific to GDS data as `Content-Type` might be incorrect on GDS presigned URL. This causes
* iframe to download file instead of showing it. This is just a work around to download the content
* and show with srcDoc in iframe.
*
* This is a temporary solution. Remove this block when permanent solution is in place.
*
* Ref: https://umccr.slack.com/archives/CP356DDCH/p1677563982961669?thread_ts=1677476635.509959&cid=CP356DDCH
* */

if (HTML_FILETYPE_LIST.includes(filetype) && presingedUrl.startsWith('https://stratus-gds')) {
return (
<div className='w-full h-full'>
<iframe className='w-full h-full bg-white' srcDoc={data} />
</div>
);
}
/** ************************* END TEMPORARY SOLUTION BLOCK ********************** */

// Return JSON
if (filetype == 'json') {
// Sanitize if JSON is
Expand Down