# svg-sanitizer
[![Build Status](https://travis-ci.org/darylldoyle/svg-sanitizer.svg?branch=master)](https://travis-ci.org/darylldoyle/svg-sanitizer) [![Test Coverage](https://codeclimate.com/github/darylldoyle/svg-sanitizer/badges/coverage.svg)](https://codeclimate.com/github/darylldoyle/svg-sanitizer/coverage)
This is my attempt at building a decent SVG sanitizer in PHP. The work is laregely borrowed from [DOMPurify](https://github.com/cure53/DOMPurify).
## Installation
Either require `enshrined/svg-sanitize` through composer or download the repo and include the old way!
## Usage
Using this is fairly easy. Create a new instance of `enshrined\svgSanitize\Sanitizer` and then call the `sanitize` whilst passing in your dirty SVG/XML
**Basic Example**
```php
use enshrined\svgSanitize\Sanitizer;
// Create a new sanitizer instance
$sanitizer = new Sanitizer();
// Load the dirty svg
$dirtySVG = file_get_contents('filthy.svg');
// Pass it to the sanitizer and get it back clean
$cleanSVG = $sanitizer->sanitize($dirtySVG);
// Now do what you want with your clean SVG/XML data
```
## Output
This will either return a sanitized SVG/XML string or boolean `false` if XML parsing failed (usually due to a badly formatted file).
## Options
You may pass your own whitelist of tags and attributes by using the `Sanitizer::setAllowedTags` and `Sanitizer::setAllowedAttrs` methods respectively.
These methods require that you implement the `enshrined\svgSanitize\data\TagInterface` or `enshrined\svgSanitize\data\AttributeInterface`.
## Remove remote references
You have the option to remove attributes that reference remote files, this will stop HTTP leaks but will add an overhead to the sanitiser.
This defaults to false, set to true to remove references.
`$sanitizer->removeRemoteReferences(true);`
## Minification
You can minify the XML output by calling `$sanitiser->minify(true);`.
## Demo
There is a demo available at: [http://svg.enshrined.co.uk/](http://svg.enshrined.co.uk/)
## WordPress
I've just released a WordPress plugin containing this code so you can sanitize your WordPress uploads. It's available from the WordPress plugin directory: [https://wordpress.org/plugins/safe-svg/](https://wordpress.org/plugins/safe-svg/)
## Drupal
[Michael Potter](https://github.com/heyMP) has kindly created a Drupal module for this library which is available at: [https://www.drupal.org/project/svg_sanitizer](https://www.drupal.org/project/svg_sanitizer)
## Tests
You can run these by running `phpunit`
## To-Do
More extensive testing for the SVGs/XML would be lovely, I'll try and add these soon. If you feel like doing it for me, please do and make a PR!
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v1.8.6.zip
共258个文件
php:93个
png:47个
css:29个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 113 浏览量
2022-04-13
07:03:02
上传
评论
收藏 2.82MB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v1.8.6 WooCommerce Advance Product Label and Badge Pro Woocommerce推进产品标签和徽章专业版" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v1.8.6.zip (258个子文件)
wobd-frontend.css 124KB
jquery.mCustomScrollbar.css 52KB
jquery.mCustomScrollbar.css 52KB
fontawesome.css 46KB
it-woocommerce-advanced-product-labels-pro.css 39KB
jquery-ui.css 34KB
font-awesome.min.css 30KB
it-woocommerce-advanced-product-labels-pro.min.css 27KB
elegant-icons.css 26KB
it-woocommerce-advanced-product-labels-pro.css 18KB
tooltipster.bundle.css 17KB
wobd-backend.css 13KB
tooltipster.bundle.css 12KB
it-woocommerce-advanced-product-labels-pro.min.css 11KB
flipclock.css 10KB
linear-style.css 8KB
flipclock.min.css 8KB
datepicker.css 7KB
wp-conditions.min.css 5KB
owl.carousel.css 5KB
owl.carousel.min.css 3KB
jquery-ui-timepicker-addon.css 2KB
icon-picker.css 2KB
style_tab.css 1KB
style_tab.min.css 1011B
fa-regular.css 686B
fa-solid.css 679B
fa-brands.css 663B
unique-style-front-end.css 0B
phpunit.xml.dist 594B
fontawesome-webfont.eot 162KB
fa-solid-900.eot 116KB
fa-brands-400.eot 109KB
ElegantIcons.eot 58KB
Linearicons-Free.eot 55KB
fa-regular-400.eot 31KB
ajax-loader.gif 3KB
thumb.gif 1KB
load.gif 433B
.gitignore 22B
tooltipster.bundle.js 117KB
icon-picker.js 97KB
owl.carousel.js 88KB
global-label-option.js 64KB
single-label-option.js 64KB
flipclock.js 54KB
jquery.mCustomScrollbar.concat.min.js 44KB
owl.carousel.min.js 43KB
single-label-option.min.js 36KB
global-label-option.min.js 32KB
flipclock.min.js 20KB
wp-color-picker-alpha.js 16KB
jquery.countdown.js 10KB
wp-conditions.js 8KB
wp-color-picker-alpha.min.js 7KB
wp-conditions.min.js 4KB
jquery.countdown.min.js 4KB
jquery.repeater.js 2KB
positioning-label.js 2KB
jquery.repeater.min.js 833B
positioning-label.min.js 211B
woocommerce-advanced-product-labels.js 28B
unique-jQuery-front-end.js 0B
unique-jQuery-front-end-related.js 0B
unique-jQuery-front-end-popup.js 0B
installed.json 1KB
composer.json 506B
composer.json 67B
LICENSE 18KB
LICENSE 1KB
composer.lock 78KB
composer.lock 2KB
README.md 3KB
it-woocommerce-advanced-product-labels-pro-en_US.mo 537B
FontAwesome.otf 132KB
html-meta-box-settings.php 69KB
html-product-tab.php 49KB
class-unique-global-labels.php 38KB
core-functions.php 27KB
class-unique-single-labels.php 19KB
class-unique-global-labels - for compatible.php 16KB
safe-svg.php 14KB
ClassLoader.php 13KB
class-unique-admin.php 11KB
class-unique-post-type.php 11KB
woocommerce-advanced-product-labels.php 11KB
Sanitizer.php 11KB
functions.php 10KB
AllowedAttributes.php 8KB
class-unique-match-conditions.php 8KB
unique-shape-style.php 7KB
html-labels-table.php 7KB
SanitizerTest.php 6KB
class-unique-condition.php 5KB
wpc-shipping-method-condition.php 5KB
AllowedTags.php 5KB
admin-functions.php 5KB
class-unique-settings.php 5KB
unique-count-down-style.php 4KB
unique-label-style.php 4KB
共 258 条
- 1
- 2
- 3
资源评论
Lee达森
- 粉丝: 968
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功