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

[FIX] Allow HTML in Toast content #306

Closed
wants to merge 1 commit into from

Conversation

mrleblanc101
Copy link

@mrleblanc101 mrleblanc101 commented Jan 26, 2022

Description

Allow HTML in Toast content

Related Issue

#248

Screenshots or GIFs (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • [] I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Maronato
Copy link
Owner

Hello Sébastien! Thanks for the PR :)
While I understand the idea and motivation for allowing raw html strings, I fear that it would be a big security issue to do so, especially given that your implementation marks all strings as such.

Unfortunately, I don't feel comfortable allowing raw html by default, and I'd rather let end users implement the solution mentioned in #248 so that they can apply it only when it is safe to do so.

Thanks again for submitting the PR, though! Please do not hesitate to submit others in the future :)

@Maronato Maronato closed this Jan 28, 2022
@mrleblanc101
Copy link
Author

mrleblanc101 commented Jan 28, 2022

I'm not sure I see the security issue if you have control over the API. Maybe I should add a props you are right, but I do think this should be in core, just like Nuxt Sweetalert 2 plugin. You can pass text or HTML if you know you have control over the content or if you know the content is correctly sanitized.

It's the same issue as v-html in general. Are you suggesting that Vue should drop v-html which is very commonly used ?

I find it very cumbersome to have to create a custom component just for that in every project.

@Maronato
Copy link
Owner

Maronato commented Jan 30, 2022

The vulnerability here is XSS. Vue's docs warns about the dangerous nature of v-html and makes it clear that it should never be used with user-generated content.

You might say that users of vue-toastification are not at risk because they control what is displayed, but that's not entirely true. What if you want to display something like ${username} liked your post!? The username is user-generated and a bad actor may use v-html to load a malicious script into the page.

This is a tiny and simple UI library. Users of it should not need to know implementation details to avoid vulnerabilities in their projects. The risks far outweigh the benefit of not having to create a custom component.

@mrleblanc101
Copy link
Author

mrleblanc101 commented Jan 30, 2022

The risk is the same as using v-html in general. Why is it ok for vue to include this but not this package ?

What is ok for vue should be ok for this plugin. As I said the HTML could be a different prop like in sweetalert and clearly documented and it wouldn't be an issue.

@Maronato Maronato mentioned this pull request Feb 11, 2022
@mrleblanc101
Copy link
Author

What if I add an allowUnsafeHtml props ? Sound like it make it clear and prevent having to recreate a custom component (by duplicating the default component) just for that.
I pushed an update to the MR.

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