2017 © Pedro Peláez
 

library php-no-html

Safely encode content for rendering in an HTML document.

image

abacaphiliac/php-no-html

Safely encode content for rendering in an HTML document.

  • Friday, August 12, 2016
  • by abacaphiliac
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Scrutinizer Code Quality Code Coverage Build Status, (*1)

abacaphiliac/php-no-html

Description

Safely encode content for rendering in an HTML document., (*2)

Brief XSS Mitigation Guide

A quote from (Paragon Initiative's blog)[https://paragonie.com/blog/2015/06/preventing-xss-vulnerabilities-in-php-everything-you-need-know]:, (*3)

  1. If your framework has a templating engine that offers automatic contextual filtering, use that.
  2. echo htmlentities($string, ENT_QUOTES | ENT_HTML5, 'UTF-8'); is a safe and effective way to stop all XSS attacks on a UTF-8 encoded web page, but doesn't allow any HTML.
  3. If your requirements allow you to use Markdown instead of HTML, don't use HTML.
  4. If you need to allow some HTML and aren't using a templating engine (see #1), use HTML Purifier.

Installation

composer require abacaphiliac/php-no-html

Usage

The following code is an example of an XSS exploit:, (*4)

$userName = 'Bob"/><script>alert('XSS');</script>';
?><input name="UserName" value="<?=$value;?>" /><?php

Simply escape the value in the response to prevent the exploit:, (*5)

$userName = 'Bob"/><script>alert('XSS');</script>';
?><input name="UserName" value="<?=\NoHtml\NoHtml::filter($value);?>" /><?php

Dependencies

See composer.json., (*6)

Contributing

composer update && vendor/bin/phing

This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request., (*7)

The Versions

12/08 2016

dev-master

9999999-dev

Safely encode content for rendering in an HTML document.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Timothy Younger

filter html xss

12/08 2016

0.2.0

0.2.0.0

Safely encode content for rendering in an HTML document.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Timothy Younger

filter html xss

12/08 2016

dev-no-html-filter

dev-no-html-filter

Safely encode content for rendering in an HTML document.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Timothy Younger

filter html xss

11/08 2016

0.1.0

0.1.0.0

Safely encode content for rendering in an HTML document.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Timothy Younger

filter html xss