Skip to content
/ escaper Public

A PHP class which offers a way to escape output and defend from XSS and related vulnerabilities by introducing HTML, CSS and Javascript escaping context.

License

Notifications You must be signed in to change notification settings

phower/escaper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phower Escaper

A PHP class which offers a way to escape output and defend from XSS and related vulnerabilities by introducing HTML, CSS and Javascript escaping context.

Phower\Escaper is inspired in Zend's escaper component and both attempt to minimize the risks from the second most important OWASP web security risk.

Instalation

This package uses Composer tool for auto-loading and dependency management. From your project root folder just run:

composer require phower/escaper

Usage

Simply instantiate your object as usual:

``` php
use Phower\Escaper;

$escaper = new Escaper();
```

Class constructor supports a argument which allows to specify a given encoding format. E.g you can escape code from iso-8859-1 using:

``` php
use Phower\Escaper;

$escaper = new Escaper('iso-8859-1');
```

This package is meant to be used for code output escaping only. Looking the implemented interface there are five methods available for that:

  • escapeHtml: escape a string for the HTML Body context.
  • escapeHtmlAttr: escape a string for the HTML Attribute context.
  • escapeJs: escape a string for the Javascript context.
  • escapeCss: escape a string for the CSS context.
  • escapeUrl: escape a string for the URI or Parameter contexts.

About

A PHP class which offers a way to escape output and defend from XSS and related vulnerabilities by introducing HTML, CSS and Javascript escaping context.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages