Skip to content

Including sanitize.js configurations in the Sanitize global object #10

@jcano

Description

@jcano

While it is possible to just copy the three files from sanitize.js to app/sanitizers/ (don't know why they are not included by default) it would be very useful to have those configurations in the global Sanitize object.

I know ember-sanitize is meant to be used as a template helper, but as it's already importing sanitize.js and it is possible to use the sanitizer from a Javascript file normally, for example to clean the user input before storing it in the database:

const s = new Sanitize( basic );
let div = document.createElement( "DIV" );
div.innerHTML = model.get( "long_text_field" );

const clean = s.clean_node( div );

div = document.createElement( "DIV" );
div.appendChild( clean );

model.set( "long_text_field", Ember.String.htmlSafe( div.innerHTML ) );

(If there is an easier way to use sanitize.js, please let me know)

By using files for configuration, every component/route/controller/service using the sanitizer would be required to navigate the paths to include the files (e.g. import basic from "../../../sanitizers/basic") with an added cost to maintain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions