PHP code example of jeffersongoncalves / laravel-html-sanitizer
1. Go to this page and download the library: Download jeffersongoncalves/laravel-html-sanitizer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jeffersongoncalves / laravel-html-sanitizer example snippets
use JeffersonGoncalves\HtmlSanitizer\HtmlSanitizer;
$dirty = '<p>Hello</p><script>alert("xss")</script><img src="x" onerror="steal()">';
$clean = HtmlSanitizer::clean($dirty);
// <p>Hello</p><img src="x">
return [
// -1 = unlimited. Symfony otherwise truncates input at 20000 bytes,
// silently cutting long READMEs/articles mid-content.
'max_input_length' => -1,
'allow_relative_links' => true,
'allow_relative_medias' => true,
'link_schemes' => ['https', 'http', 'mailto'],
// 'data' is intentionally omitted: data:image/svg+xml can carry script.
'media_schemes' => ['https', 'http'],
'attributes' => [
'class' => '*',
'id' => '*',
'width' => ['img'],
'height' => ['img'],
],
];
bash
php artisan vendor:publish --tag="html-sanitizer-config"