Version Description
- Allow SVGZ uploads
Download this release
Release Info
| Developer | enshrined |
| Plugin | |
| Version | 1.3.3 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3.1 to 1.3.3
- licence.txt +1 -1
- readme.txt +8 -2
- safe-svg.php +32 -2
licence.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
Safe SVG - Upload and sanitize SVGs within
|
| 2 |
|
| 3 |
Copyright 2015 Daryll Doyle
|
| 4 |
|
| 1 |
+
Safe SVG - Upload and sanitize SVGs within WordPress
|
| 2 |
|
| 3 |
Copyright 2015 Daryll Doyle
|
| 4 |
|
readme.txt
CHANGED
|
@@ -3,8 +3,8 @@ Contributors: enshrined
|
|
| 3 |
Donate link: http://enshrined.co.uk
|
| 4 |
Tags: svg, sanitize, uploads, sanitise, security, svg upload
|
| 5 |
Requires at least: 4.0
|
| 6 |
-
Tested up to: 4.
|
| 7 |
-
Stable tag: 1.3.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -43,3 +43,9 @@ Install through the WordPress directory or download, unzip and upload the files
|
|
| 43 |
|
| 44 |
= 1.3.1 =
|
| 45 |
* Updated underlying library version
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
Donate link: http://enshrined.co.uk
|
| 4 |
Tags: svg, sanitize, uploads, sanitise, security, svg upload
|
| 5 |
Requires at least: 4.0
|
| 6 |
+
Tested up to: 4.7.2
|
| 7 |
+
Stable tag: 1.3.3
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 43 |
|
| 44 |
= 1.3.1 =
|
| 45 |
* Updated underlying library version
|
| 46 |
+
|
| 47 |
+
= 1.3.2 =
|
| 48 |
+
* Fix for the mime type issue in 4.7.1. Mad props to @lewiscowles
|
| 49 |
+
|
| 50 |
+
= 1.3.3 =
|
| 51 |
+
* Allow SVGZ uploads
|
safe-svg.php
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
/*
|
| 3 |
Plugin Name: Safe SVG
|
| 4 |
Plugin URI: https://wordpress.org/plugins/safe-svg/
|
| 5 |
-
Description: Allows SVG uploads into
|
| 6 |
-
Version: 1.3.
|
| 7 |
Author: Daryll Doyle
|
| 8 |
Author URI: http://enshrined.co.uk
|
| 9 |
Text Domain: safe-svg
|
|
@@ -37,6 +37,7 @@ if ( ! class_exists( 'safe_svg' ) ) {
|
|
| 37 |
|
| 38 |
add_filter( 'upload_mimes', array( $this, 'allow_svg' ) );
|
| 39 |
add_filter( 'wp_handle_upload_prefilter', array( $this, 'check_for_svg' ) );
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
/**
|
|
@@ -48,10 +49,39 @@ if ( ! class_exists( 'safe_svg' ) ) {
|
|
| 48 |
*/
|
| 49 |
public function allow_svg( $mimes ) {
|
| 50 |
$mimes['svg'] = 'image/svg+xml';
|
|
|
|
| 51 |
|
| 52 |
return $mimes;
|
| 53 |
}
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
/**
|
| 56 |
* Check if the file is an SVG, if so handle appropriately
|
| 57 |
*
|
| 2 |
/*
|
| 3 |
Plugin Name: Safe SVG
|
| 4 |
Plugin URI: https://wordpress.org/plugins/safe-svg/
|
| 5 |
+
Description: Allows SVG uploads into WordPress and sanitizes the SVG before saving it
|
| 6 |
+
Version: 1.3.3
|
| 7 |
Author: Daryll Doyle
|
| 8 |
Author URI: http://enshrined.co.uk
|
| 9 |
Text Domain: safe-svg
|
| 37 |
|
| 38 |
add_filter( 'upload_mimes', array( $this, 'allow_svg' ) );
|
| 39 |
add_filter( 'wp_handle_upload_prefilter', array( $this, 'check_for_svg' ) );
|
| 40 |
+
add_filter( 'wp_check_filetype_and_ext', array( $this, 'fix_mime_type_svg' ), 75, 4 );
|
| 41 |
}
|
| 42 |
|
| 43 |
/**
|
| 49 |
*/
|
| 50 |
public function allow_svg( $mimes ) {
|
| 51 |
$mimes['svg'] = 'image/svg+xml';
|
| 52 |
+
$mimes['svgz'] = 'image/svg+xml';
|
| 53 |
|
| 54 |
return $mimes;
|
| 55 |
}
|
| 56 |
|
| 57 |
+
/**
|
| 58 |
+
* Fixes the issue in WordPress 4.7.1 being unable to correctly identify SVGs
|
| 59 |
+
*
|
| 60 |
+
* @thanks @lewiscowles
|
| 61 |
+
*
|
| 62 |
+
* @param null $data
|
| 63 |
+
* @param null $file
|
| 64 |
+
* @param null $filename
|
| 65 |
+
* @param null $mimes
|
| 66 |
+
*
|
| 67 |
+
* @return null
|
| 68 |
+
*/
|
| 69 |
+
public function fix_mime_type_svg( $data = null, $file = null, $filename = null, $mimes = null ) {
|
| 70 |
+
$ext = isset( $data['ext'] ) ? $data['ext'] : '';
|
| 71 |
+
if ( strlen( $ext ) < 1 ) {
|
| 72 |
+
$ext = strtolower( end( explode( '.', $filename ) ) );
|
| 73 |
+
}
|
| 74 |
+
if ( $ext === 'svg' ) {
|
| 75 |
+
$data['type'] = 'image/svg+xml';
|
| 76 |
+
$data['ext'] = 'svg';
|
| 77 |
+
} elseif ( $ext === 'svgz' ) {
|
| 78 |
+
$data['type'] = 'image/svg+xml';
|
| 79 |
+
$data['ext'] = 'svgz';
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
return $data;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
/**
|
| 86 |
* Check if the file is an SVG, if so handle appropriately
|
| 87 |
*
|
