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

Added rich HTML previewer #40

Merged
merged 6 commits into from
Oct 3, 2023
Merged

Conversation

JR-1991
Copy link
Member

@JR-1991 JR-1991 commented Aug 7, 2023

Overview

As discussed in issue #31 and in previous chats with @qqmyers and @pdurbin, this PR introduces an insecure HTML previewer to allow users to display pages that contain script tags. This is especially useful in cases where interactive figures or other third-party libraries are involved in rendering data.

How it works

Upon redirecting to the external tool, the user is presented with a confirmation window that discloses the potential risks of using the previewer. The whole HTML page will be rendered with its script content if given consent. The user will be redirected to the dataset page if no consent is given.

Example

I've included an example based on an example found on this DaRUS file using Plotly for an interactive plot. For reproducibility adapt the following URL:

http://localhost:3001/previewers/betatest/RichHtmlPreview?fileid=198953&siteUrl=https://darus.uni-stuttgart.de&datasetid=198952&datasetversion=1.0

Using the default HTML previewer

image

Using the rich HTML previewer from this PR

image

The consent message

image

@@ -50,6 +50,31 @@ curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin
}'
```

> The following HTML previewer allows users, after consent, to display HTML files that contain scripts for plotting etc. Please note, that this should not to be confused with the default HTML previewer. If you do NOT wish to add this previewer, please make sure to use the one above.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW: I'm OK with just calling this something like 'Rich HTML Previewer' in terms of class name and labels and just having text here that says 'Rich HTML Previewer - Potential Issues if used with malicious content'.

Copy link
Member Author

@JR-1991 JR-1991 Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, would you also suggest renaming the corresponding js and html files to richhtml.js and RichHtmlPreview.html, respectively? Sounds less scary than "insecure".

@@ -0,0 +1,64 @@
$(document).ready(function () {

const MESSAGE = "This data file includes JavaScript which may need to run for the data to display properly.\n\nYou can click the OK to allow the JavaScript to run, but be sure you trust this datafile as a malicious JavaScript could harm your computer (with the same concerns as if you went to a malicious website outside of Dataverse).\n\nIf you wish to not run the complete page, click Abort to be redirected to Dataverse."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the $.i18n mechanism for this text?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't used i18n before. Is this the correct usage?

$.i18n(...message...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~yes - your message text goes in https://github.com/gdcc/dataverse-previewers/blob/develop/previewers/betatest/i18n/en.json and you reference by the title you give it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just commited the changes.

@JR-1991 JR-1991 changed the title Added insecure HTML previewer Added rich HTML previewer Aug 8, 2023
@qqmyers qqmyers merged commit 81c4682 into gdcc:develop Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants