npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-sanitize-escape

v0.0.3

Published

Vue.js plugin for sanitizing and escaping user input to protect against XSS, SQL injection, and other security vulnerabilities.

Downloads

641

Readme

vue-sanitize-escape

npm version License Build Status Test Coverage

A Vue.js plugin to fortify your application against common web vulnerabilities like Cross-Site Scripting (XSS), SQL Injection, and Open Redirects.

Features

  • Sanitization:
    • Deeply sanitizes strings, numbers, objects, and arrays.
    • Removes dangerous HTML tags (e.g., , , on* attributes).
    • Neutralizes potential SQL injection attempts.
    • Protects against open redirect attacks.
  • Escaping:
    • Escapes special characters in strings to prevent XSS vulnerabilities.
  • Vue.js Integration:
    • Simple installation as a Vue plugin.
    • Convenient $sanitizeEscape object for direct access to functions.
    • Custom Vue directive (v-sanitize) for automatic input sanitization.
  • Lightweight and Dependency-Free:
    • No external dependencies, ensuring minimal overhead.
    • Focused on core sanitization and escaping tasks.
  • Support for the Vitejs based projects

Installation

npm install vue-sanitize-escape

Usage

Vue.js

import Vue from 'vue';
import VueSanitizeEscape from 'vue-sanitize-escape';

// Sanitizes all inputs by default. In this case no need to use v-sanitize directive
Vue.use(VueSanitizeEscape, { sanitizeAll: true });

// sanitizeAll defaults to false
Vue.use(VueSanitizeEscape);

Sanitize Input

this.$sanitizeEscape.sanitize(userInput, type);
  • userInput: The input to sanitize (string, number, object, array).
  • type: Optional (default: 'string'). Specifies the type of the input.

Escape HTML Entities

this.$sanitizeEscape.escape(userInput);

v-sanitize Directive

<input type="text" v-model="userInput" v-sanitize />

This directive will automatically sanitize the input on change. You can optionally specify the type as an argument:

<input type="number" v-model="userAge" v-sanitize:number />

Why Use vue-sanitize-escape?

  • Ease of Use: Seamlessly integrates with Vue.js projects.
  • Option to integrate by default for all inputs. Otherwise, it can be used for the targeted inputs.
  • No Dependencies: Avoids the overhead and potential vulnerabilities of third-party libraries.
  • Customizable: Tailor the sanitization behavior to your specific needs by extending or modifying the core functions.
  • Performance: Designed to be lightweight and efficient, minimizing impact on your application's performance.
  • Security-Focused: Specifically crafted to address common web vulnerabilities and enhance the security of your Vue.js application.
  • Regularly Updated: The library will be actively maintained to adapt to new security threats and best practices.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

License

This project is licensed under the MIT License.