From de3bf85b288696f86443c5ae29130651fd805132 Mon Sep 17 00:00:00 2001 From: Curtis ROck Date: Sat, 26 Sep 2020 12:22:22 -0500 Subject: [PATCH] Added PDF filetype detection and rendering via iFrame, but get CSP related issue of trying to embed remote content into an iFrame. Applied to both timeline and profile media gallery --- app/soapbox/components/media_gallery.js | 33 ++++++++++++++----- .../account_gallery/components/media_item.js | 29 ++++++++++++++-- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/app/soapbox/components/media_gallery.js b/app/soapbox/components/media_gallery.js index 3eda57795..149aa3740 100644 --- a/app/soapbox/components/media_gallery.js +++ b/app/soapbox/components/media_gallery.js @@ -147,15 +147,30 @@ class Item extends React.PureComponent { if (attachment.get('type') === 'unknown') { const filename = truncateFilename(attachment.get('remote_url'), MAX_FILENAME_LENGTH); - return ( -
- - - - {filename} - -
- ); + var re = /(?:\.([^.]+))?$/; + const type = re.exec(filename)[1]; // e.g. "pdf" + if(type === 'pdf') { + return ( +
+