mongoose-dompurify

1.4.1 • Public • Published

mongoose-dompurify

Build Status Dependency Status Download Status Sponsor on GitHub

DOMPurify plugin for Mongoose schemas that sanitizes documents before saving.

Installation

$ npm install --save mongoose-dompurify

Usage

const sanitizerPlugin = require('mongoose-dompurify');

MyMongooseSchema.plugin(sanitizerPlugin, {
  // Do not sanitize these fields (default: [])
  skip: [],

  // Encode HTML entities? (default: false)
  encodeHtmlEntities: false,

  // Configure DOMPurify, see https://github.com/cure53/DOMPurify for a list of options (default: undefined)
  sanitizer: {
    SAFE_FOR_JQUERY: true,
    SAFE_FOR_TEMPLATES: true,
    ALLOWED_TAGS: []
  }
});

When saving a document generated with MyMongooseSchema, mongoose-dompurify will automatically perform sanitization before saving to the database.

License

(The MIT License)

Copyright (c) 2017 Jonathon Hill jhill9693@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i mongoose-dompurify

Weekly Downloads

2

Version

1.4.1

License

MIT

Unpacked Size

22.4 kB

Total Files

9

Last publish

Collaborators

  • compwright