Safe SVG - Version 1.4.5

Version Description

  • Fixes some issues with defining the size of an SVG.
  • Library update
Download this release

Release Info

Developer enshrined
Plugin Icon 128x128 Safe SVG
Version 1.4.5
Comparing to
See all releases

Code changes from version 1.4.4 to 1.4.5

lib/composer.lock CHANGED
@@ -9,16 +9,16 @@
9
  "packages": [
10
  {
11
  "name": "enshrined/svg-sanitize",
12
- "version": "0.5.2",
13
  "source": {
14
  "type": "git",
15
  "url": "https://github.com/darylldoyle/svg-sanitizer.git",
16
- "reference": "59abb58f5cf68e55be5bfb93574c0e055c2a577d"
17
  },
18
  "dist": {
19
  "type": "zip",
20
- "url": "https://api.github.com/repos/darylldoyle/svg-sanitizer/zipball/59abb58f5cf68e55be5bfb93574c0e055c2a577d",
21
- "reference": "59abb58f5cf68e55be5bfb93574c0e055c2a577d",
22
  "shasum": ""
23
  },
24
  "require-dev": {
@@ -42,7 +42,7 @@
42
  }
43
  ],
44
  "description": "An SVG sanitizer for PHP",
45
- "time": "2017-02-23 17:42:17"
46
  }
47
  ],
48
  "packages-dev": [],
9
  "packages": [
10
  {
11
  "name": "enshrined/svg-sanitize",
12
+ "version": "0.6.0",
13
  "source": {
14
  "type": "git",
15
  "url": "https://github.com/darylldoyle/svg-sanitizer.git",
16
+ "reference": "0c943fe5fe0acb30f4c80f3a4602c44498f95eff"
17
  },
18
  "dist": {
19
  "type": "zip",
20
+ "url": "https://api.github.com/repos/darylldoyle/svg-sanitizer/zipball/0c943fe5fe0acb30f4c80f3a4602c44498f95eff",
21
+ "reference": "0c943fe5fe0acb30f4c80f3a4602c44498f95eff",
22
  "shasum": ""
23
  },
24
  "require-dev": {
42
  }
43
  ],
44
  "description": "An SVG sanitizer for PHP",
45
+ "time": "2017-06-11 23:08:25"
46
  }
47
  ],
48
  "packages-dev": [],
lib/vendor/composer/installed.json CHANGED
@@ -1,24 +1,24 @@
1
  [
2
  {
3
  "name": "enshrined/svg-sanitize",
4
- "version": "0.5.2",
5
- "version_normalized": "0.5.2.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/darylldoyle/svg-sanitizer.git",
9
- "reference": "59abb58f5cf68e55be5bfb93574c0e055c2a577d"
10
  },
11
  "dist": {
12
  "type": "zip",
13
- "url": "https://api.github.com/repos/darylldoyle/svg-sanitizer/zipball/59abb58f5cf68e55be5bfb93574c0e055c2a577d",
14
- "reference": "59abb58f5cf68e55be5bfb93574c0e055c2a577d",
15
  "shasum": ""
16
  },
17
  "require-dev": {
18
  "codeclimate/php-test-reporter": "^0.1.2",
19
  "phpunit/phpunit": "^4.7"
20
  },
21
- "time": "2017-02-23 17:42:17",
22
  "type": "library",
23
  "installation-source": "dist",
24
  "autoload": {
1
  [
2
  {
3
  "name": "enshrined/svg-sanitize",
4
+ "version": "0.6.0",
5
+ "version_normalized": "0.6.0.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/darylldoyle/svg-sanitizer.git",
9
+ "reference": "0c943fe5fe0acb30f4c80f3a4602c44498f95eff"
10
  },
11
  "dist": {
12
  "type": "zip",
13
+ "url": "https://api.github.com/repos/darylldoyle/svg-sanitizer/zipball/0c943fe5fe0acb30f4c80f3a4602c44498f95eff",
14
+ "reference": "0c943fe5fe0acb30f4c80f3a4602c44498f95eff",
15
  "shasum": ""
16
  },
17
  "require-dev": {
18
  "codeclimate/php-test-reporter": "^0.1.2",
19
  "phpunit/phpunit": "^4.7"
20
  },
21
+ "time": "2017-06-11 23:08:25",
22
  "type": "library",
23
  "installation-source": "dist",
24
  "autoload": {
lib/vendor/enshrined/svg-sanitize/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
  /vendor
2
  /build
 
1
  /vendor
2
  /build
3
+ /.idea
lib/vendor/enshrined/svg-sanitize/.travis.yml CHANGED
@@ -5,7 +5,6 @@ php:
5
  - 5.5
6
  - 5.6
7
  - 7.0
8
- - hhvm
9
 
10
  before_script:
11
  - composer install --dev
5
  - 5.5
6
  - 5.6
7
  - 7.0
 
8
 
9
  before_script:
10
  - composer install --dev
lib/vendor/enshrined/svg-sanitize/src/Sanitizer.php CHANGED
@@ -149,6 +149,9 @@ class Sanitizer
149
  return '';
150
  }
151
 
 
 
 
152
  $this->setUpBefore();
153
 
154
  $loaded = $this->xmlDocument->loadXML($dirty);
@@ -168,7 +171,7 @@ class Sanitizer
168
  $this->startClean($allElements);
169
 
170
  // Save cleaned XML to a variable
171
- $clean = $this->xmlDocument->saveXML($this->xmlDocument->documentElement, LIBXML_NOEMPTYTAG);
172
 
173
  $this->resetAfter();
174
 
@@ -321,4 +324,4 @@ class Sanitizer
321
  {
322
  $this->minifyXML = (bool) $shouldMinify;
323
  }
324
- }
149
  return '';
150
  }
151
 
152
+ // Strip php tags
153
+ $dirty = preg_replace('/<\?(=|php)(.+?)\?>/i', '', $dirty);
154
+
155
  $this->setUpBefore();
156
 
157
  $loaded = $this->xmlDocument->loadXML($dirty);
171
  $this->startClean($allElements);
172
 
173
  // Save cleaned XML to a variable
174
+ $clean = $this->xmlDocument->saveXML($this->xmlDocument, LIBXML_NOEMPTYTAG);
175
 
176
  $this->resetAfter();
177
 
324
  {
325
  $this->minifyXML = (bool) $shouldMinify;
326
  }
327
+ }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpsvg.com/
4
  Tags: svg, sanitize, upload, sanitise, security, svg upload, image, vector, file, graphic, media, mime
5
  Requires at least: 4.0
6
  Tested up to: 4.8.0
7
- Stable tag: 1.4.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -39,6 +39,10 @@ Install through the WordPress directory or download, unzip and upload the files
39
 
40
  == Changelog ==
41
 
 
 
 
 
42
  = 1.4.4 =
43
  * SVGs now display as featured images in the admin area
44
 
4
  Tags: svg, sanitize, upload, sanitise, security, svg upload, image, vector, file, graphic, media, mime
5
  Requires at least: 4.0
6
  Tested up to: 4.8.0
7
+ Stable tag: 1.4.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
39
 
40
  == Changelog ==
41
 
42
+ = 1.4.5 =
43
+ * Fixes some issues with defining the size of an SVG.
44
+ * Library update
45
+
46
  = 1.4.4 =
47
  * SVGs now display as featured images in the admin area
48
 
safe-svg.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Safe SVG
4
  Plugin URI: https://wpsvg.com/
5
  Description: Allows SVG uploads into WordPress and sanitizes the SVG before saving it
6
- Version: 1.4.4
7
  Author: Daryll Doyle
8
  Author URI: http://enshrined.co.uk
9
  Text Domain: safe-svg
@@ -42,6 +42,7 @@ if ( ! class_exists( 'safe_svg' ) ) {
42
  add_filter( 'wp_get_attachment_image_src', array( $this, 'one_pixel_fix' ), 10, 4 );
43
  add_filter( 'admin_post_thumbnail_html', array( $this, 'featured_image_fix' ), 10, 3 );
44
  add_action( 'admin_enqueue_scripts', array( $this, 'load_custom_admin_style' ) );
 
45
  }
46
 
47
  /**
@@ -208,8 +209,8 @@ if ( ! class_exists( 'safe_svg' ) ) {
208
  */
209
  public function one_pixel_fix( $image, $attachment_id, $size, $icon ) {
210
  if ( get_post_mime_type( $attachment_id ) == 'image/svg+xml' ) {
211
- $image['1'] = 100;
212
- $image['2'] = 100;
213
  }
214
 
215
  return $image;
@@ -241,6 +242,30 @@ if ( ! class_exists( 'safe_svg' ) ) {
241
  wp_enqueue_style( 'safe-svg-css', plugins_url( 'assets/safe-svg.css', __FILE__ ), array() );
242
  }
243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
  }
246
 
3
  Plugin Name: Safe SVG
4
  Plugin URI: https://wpsvg.com/
5
  Description: Allows SVG uploads into WordPress and sanitizes the SVG before saving it
6
+ Version: 1.4.5
7
  Author: Daryll Doyle
8
  Author URI: http://enshrined.co.uk
9
  Text Domain: safe-svg
42
  add_filter( 'wp_get_attachment_image_src', array( $this, 'one_pixel_fix' ), 10, 4 );
43
  add_filter( 'admin_post_thumbnail_html', array( $this, 'featured_image_fix' ), 10, 3 );
44
  add_action( 'admin_enqueue_scripts', array( $this, 'load_custom_admin_style' ) );
45
+ add_action( 'get_image_tag', array( $this, 'get_image_tag_override' ), 10, 6 );
46
  }
47
 
48
  /**
209
  */
210
  public function one_pixel_fix( $image, $attachment_id, $size, $icon ) {
211
  if ( get_post_mime_type( $attachment_id ) == 'image/svg+xml' ) {
212
+ $image['1'] = false;
213
+ $image['2'] = false;
214
  }
215
 
216
  return $image;
242
  wp_enqueue_style( 'safe-svg-css', plugins_url( 'assets/safe-svg.css', __FILE__ ), array() );
243
  }
244
 
245
+ /**
246
+ * Override the default height and width string on an SVG
247
+ *
248
+ * @param string $html HTML content for the image.
249
+ * @param int $id Attachment ID.
250
+ * @param string $alt Alternate text.
251
+ * @param string $title Attachment title.
252
+ * @param string $align Part of the class name for aligning the image.
253
+ * @param string|array $size Size of image. Image size or array of width and height values (in that order).
254
+ * Default 'medium'.
255
+ *
256
+ * @return mixed
257
+ */
258
+ function get_image_tag_override( $html, $id, $alt, $title, $align, $size ) {
259
+ $mime = get_post_mime_type( $id );
260
+
261
+ if( 'image/svg+xml' === $mime ) {
262
+ $html = str_replace('width="1" ', '', $html);
263
+ $html = str_replace('height="1" ', '', $html);
264
+ }
265
+
266
+ return $html;
267
+ }
268
+
269
  }
270
  }
271