Download the PHP package laravelgems/escape without Composer
On this page you can find all versions of the php package laravelgems/escape. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravelgems/escape
More information about laravelgems/escape
Files in laravelgems/escape
Package escape
Short Description Basic methods to escape untrusted data before inserting into different HTML contexts
License MIT
Homepage https://github.com/laravelgems/escape
Informations about the package escape
Make your pages safer
This library provides several methods that help you prevent XSS attacks on your pages.
These methods escape untrusted data properly. Just follow simple rules and you're safe.
Quick example
Important:
- this library does not do any validation
- this library does not clean invalid/dangerous code
So, please do not expect that this library will protect you from something like this:
Installation
Include HTML.php
or install the composer package
HTML text
This methods uses htmlspecialchars
with small addition (escaping forward slash too).
HTML attribute
Important - this is only safe for whitelist of attributes
Whitelist: align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width
Some attributes (for example, ID
) is not in a whitelist as it can be used for breaking your frontend logic by processing/watching wrong element.
Many other attributes are potentially dangerous even with properly escaped data.
CSS
Notes:
- value should be quoted
- stay away from putting untrusted data into complex properties like url, behavior, and custom (-moz-binding)
- do not put untrusted data into IE’s expression property value which allows JavaScript.
Javascript variable
URL parameter
FYI, this method is an alias to urlencode
.
Warning! Never ever make something like these without validation/sanitizing
More examples (wrong vs right)
Inspiration
Thanks to QWASP for their top 10 and cheat sheets. Thanks to Twig library for their filters.
All versions of escape with dependencies
ext-iconv Version *