EvolvedWeb / evowc

Evolved Web Components
MIT License
8 stars 0 forks source link

Provide a way for developers to define an HTML sanitizer into Evo for `:html` #88

Open intervalia opened 7 months ago

intervalia commented 7 months ago

Describe the solution you'd like Instead of adding a fixed HTML sanitizer and in preparation the built in Sanitizer Evo needs a way for a developer to add an HTML sanitizer of their choice. https://devdocs.io/dom/sanitizer

This may be as simple as creating an HTML sanitizer pipe.

intervalia commented 7 months ago

For now we will create a new project that anyone can use (https://github.com/evolvedweb/evo-sanitize) This will incorporate DOMPurify (https://www.npmjs.com/package/dompurify)

We will export both a sanitize function and a function to provide/remove named config options.

The sanitize pipe function will utilize the attribute data-sanitize="<option name"> to pick which set of options are to be used.

If the specified options are not found we will use console.error to let them know that options by that name do not exist and we will use the default options.

Since this pipe is really just an exported function this can be used at any time in the code.

In the future we may either replace this pipe or create a new pipe that uses the built in sanitizer (https://devdocs.io/dom/sanitizer)

intervalia commented 7 months ago

We will need to update the command evowc init to ask if they want to also install EvoSanitizePipe. If they do then we will add the two needed projects into their package.json file.

We will also probably need a way to copy the file EvoSanitizePipe.js to a path of their choosing, defaulting to the location of the file EvoElement.js as part of the post install for the repo Evo Sanitize Pipe.