Safe SVG - Version 1.1.0

Version Description

  • Added i18n
  • Added da, de ,en, es, fr, nl and ru translations
  • Fixed an issue with filename not being pulled over on failed uploads
Download this release

Release Info

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

Code changes from version 1.0.0 to 1.1.0

languages/safe-svg-da_DK.mo ADDED
Binary file
languages/safe-svg-da_DK.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "MIME-Version: 1.0\n"
4
+ "Content-Type: text/plain; charset=UTF-8\n"
5
+ "Content-Transfer-Encoding: 8bit\n"
6
+ "X-Generator: POEditor.com\n"
7
+ "Project-Id-Version: Safe SVG\n"
8
+ "Language: da\n"
9
+
10
+ #: safe-svg.php:66
11
+ msgid "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded"
12
+ msgstr "Beklager, kunne denne fil ikke desinficeres, så af sikkerhedsmæssige årsager ikke er uploadet"
13
+
14
+ #. Plugin Name of the plugin/theme
15
+ #:
16
+ msgid "Safe SVG"
17
+ msgstr "Sikker SVG"
18
+
19
+ #. Plugin URI of the plugin/theme
20
+ #:
21
+ msgid "https://wordpress.org/plugins/safe-svg/"
22
+ msgstr "https://wordpress.org/plugins/safe-svg/"
23
+
24
+ #. Description of the plugin/theme
25
+ #:
26
+ msgid "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
27
+ msgstr "Tillader SVG uploads i Wordpress og renser SVG før du gemmer det"
28
+
29
+ #. Author of the plugin/theme
30
+ #:
31
+ msgid "Daryll Doyle"
32
+ msgstr "Daryll Doyle"
33
+
34
+ #. Author URI of the plugin/theme
35
+ #:
36
+ msgid "http://enshrined.co.uk"
37
+ msgstr "http://enshrined.co.uk"
38
+
languages/safe-svg-de_DE.mo ADDED
Binary file
languages/safe-svg-de_DE.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "MIME-Version: 1.0\n"
4
+ "Content-Type: text/plain; charset=UTF-8\n"
5
+ "Content-Transfer-Encoding: 8bit\n"
6
+ "X-Generator: POEditor.com\n"
7
+ "Project-Id-Version: Safe SVG\n"
8
+ "Language: de\n"
9
+
10
+ #: safe-svg.php:66
11
+ msgid "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded"
12
+ msgstr "Leider konnte diese Datei nicht bereinigt, damit aus Sicherheitsgründen nicht hochgeladen wurde sein"
13
+
14
+ #. Plugin Name of the plugin/theme
15
+ #:
16
+ msgid "Safe SVG"
17
+ msgstr "Safe SVG"
18
+
19
+ #. Plugin URI of the plugin/theme
20
+ #:
21
+ msgid "https://wordpress.org/plugins/safe-svg/"
22
+ msgstr "https://wordpress.org/plugins/safe-svg/"
23
+
24
+ #. Description of the plugin/theme
25
+ #:
26
+ msgid "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
27
+ msgstr "Ermöglicht SVG Uploads in Wordpress und reinigt die SVG vor dem Speichern"
28
+
29
+ #. Author of the plugin/theme
30
+ #:
31
+ msgid "Daryll Doyle"
32
+ msgstr "Daryll Doyle"
33
+
34
+ #. Author URI of the plugin/theme
35
+ #:
36
+ msgid "http://enshrined.co.uk"
37
+ msgstr "http://enshrined.co.uk"
38
+
languages/safe-svg-en_GB.mo ADDED
Binary file
languages/safe-svg-en_GB.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "MIME-Version: 1.0\n"
4
+ "Content-Type: text/plain; charset=UTF-8\n"
5
+ "Content-Transfer-Encoding: 8bit\n"
6
+ "X-Generator: POEditor.com\n"
7
+ "Project-Id-Version: Safe SVG\n"
8
+ "Language: en\n"
9
+
10
+ #: safe-svg.php:66
11
+ msgid "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded"
12
+ msgstr "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded "
13
+
14
+ #. Plugin Name of the plugin/theme
15
+ #:
16
+ msgid "Safe SVG"
17
+ msgstr "Safe SVG "
18
+
19
+ #. Plugin URI of the plugin/theme
20
+ #:
21
+ msgid "https://wordpress.org/plugins/safe-svg/"
22
+ msgstr "https://wordpress.org/plugins/safe-svg/"
23
+
24
+ #. Description of the plugin/theme
25
+ #:
26
+ msgid "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
27
+ msgstr "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
28
+
29
+ #. Author of the plugin/theme
30
+ #:
31
+ msgid "Daryll Doyle"
32
+ msgstr "Daryll Doyle"
33
+
34
+ #. Author URI of the plugin/theme
35
+ #:
36
+ msgid "http://enshrined.co.uk"
37
+ msgstr "http://enshrined.co.uk"
38
+
languages/safe-svg-es_ES.mo ADDED
Binary file
languages/safe-svg-es_ES.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "MIME-Version: 1.0\n"
4
+ "Content-Type: text/plain; charset=UTF-8\n"
5
+ "Content-Transfer-Encoding: 8bit\n"
6
+ "X-Generator: POEditor.com\n"
7
+ "Project-Id-Version: Safe SVG\n"
8
+ "Language: es\n"
9
+
10
+ #: safe-svg.php:66
11
+ msgid "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded"
12
+ msgstr "Lo sentimos, este fichero no pudo ser desinfectados por razones de seguridad no fue subido"
13
+
14
+ #. Plugin Name of the plugin/theme
15
+ #:
16
+ msgid "Safe SVG"
17
+ msgstr "SVG Segura"
18
+
19
+ #. Plugin URI of the plugin/theme
20
+ #:
21
+ msgid "https://wordpress.org/plugins/safe-svg/"
22
+ msgstr "https://wordpress.org/plugins/safe-svg/"
23
+
24
+ #. Description of the plugin/theme
25
+ #:
26
+ msgid "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
27
+ msgstr "Permite archivos SVG en Wordpress y desinfecta el SVG antes de guardarlo"
28
+
29
+ #. Author of the plugin/theme
30
+ #:
31
+ msgid "Daryll Doyle"
32
+ msgstr "Daryll Doyle"
33
+
34
+ #. Author URI of the plugin/theme
35
+ #:
36
+ msgid "http://enshrined.co.uk"
37
+ msgstr "http://enshrined.co.uk"
38
+
languages/safe-svg-fr_FR.mo ADDED
Binary file
languages/safe-svg-fr_FR.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "MIME-Version: 1.0\n"
4
+ "Content-Type: text/plain; charset=UTF-8\n"
5
+ "Content-Transfer-Encoding: 8bit\n"
6
+ "X-Generator: POEditor.com\n"
7
+ "Project-Id-Version: Safe SVG\n"
8
+ "Language: fr\n"
9
+
10
+ #: safe-svg.php:66
11
+ msgid "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded"
12
+ msgstr "Désolé, ce fichier n'a pas pu être désinfectés pour des raisons de sécurité n'a pas été téléchargé"
13
+
14
+ #. Plugin Name of the plugin/theme
15
+ #:
16
+ msgid "Safe SVG"
17
+ msgstr "Safe SVG"
18
+
19
+ #. Plugin URI of the plugin/theme
20
+ #:
21
+ msgid "https://wordpress.org/plugins/safe-svg/"
22
+ msgstr "https://wordpress.org/plugins/safe-svg/"
23
+
24
+ #. Description of the plugin/theme
25
+ #:
26
+ msgid "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
27
+ msgstr "Permet le téléchargement de SVG en Wordpress et assainit le SVG avant de l'enregistrer"
28
+
29
+ #. Author of the plugin/theme
30
+ #:
31
+ msgid "Daryll Doyle"
32
+ msgstr "Daryll Doyle"
33
+
34
+ #. Author URI of the plugin/theme
35
+ #:
36
+ msgid "http://enshrined.co.uk"
37
+ msgstr "http://enshrined.co.uk"
38
+
languages/safe-svg-nl_NL.mo ADDED
Binary file
languages/safe-svg-nl_NL.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "MIME-Version: 1.0\n"
4
+ "Content-Type: text/plain; charset=UTF-8\n"
5
+ "Content-Transfer-Encoding: 8bit\n"
6
+ "X-Generator: POEditor.com\n"
7
+ "Project-Id-Version: Safe SVG\n"
8
+ "Language: nl\n"
9
+
10
+ #: safe-svg.php:66
11
+ msgid "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded"
12
+ msgstr "Sorry, dit bestand kan niet worden opgeschoond, zodat om veiligheidsredenen werd niet geupload"
13
+
14
+ #. Plugin Name of the plugin/theme
15
+ #:
16
+ msgid "Safe SVG"
17
+ msgstr "Safe SVG"
18
+
19
+ #. Plugin URI of the plugin/theme
20
+ #:
21
+ msgid "https://wordpress.org/plugins/safe-svg/"
22
+ msgstr "https://wordpress.org/plugins/safe-svg/"
23
+
24
+ #. Description of the plugin/theme
25
+ #:
26
+ msgid "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
27
+ msgstr "Hiermee kunnen SVG upload in Wordpress en reinigt de SVG alvorens deze op te slaan"
28
+
29
+ #. Author of the plugin/theme
30
+ #:
31
+ msgid "Daryll Doyle"
32
+ msgstr "Daryll Doyle"
33
+
34
+ #. Author URI of the plugin/theme
35
+ #:
36
+ msgid "http://enshrined.co.uk"
37
+ msgstr "http://enshrined.co.uk"
38
+
languages/safe-svg-ru_RU.mo ADDED
Binary file
languages/safe-svg-ru_RU.po ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "MIME-Version: 1.0\n"
4
+ "Content-Type: text/plain; charset=UTF-8\n"
5
+ "Content-Transfer-Encoding: 8bit\n"
6
+ "X-Generator: POEditor.com\n"
7
+ "Project-Id-Version: Safe SVG\n"
8
+ "Language: ru\n"
9
+
10
+ #: safe-svg.php:66
11
+ msgid "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded"
12
+ msgstr "К сожалению, этот файл не может быть продезинфицировать так по соображениям безопасности не был загружен"
13
+
14
+ #. Plugin Name of the plugin/theme
15
+ #:
16
+ msgid "Safe SVG"
17
+ msgstr "Безопасный SVG"
18
+
19
+ #. Plugin URI of the plugin/theme
20
+ #:
21
+ msgid "https://wordpress.org/plugins/safe-svg/"
22
+ msgstr "https://wordpress.org/plugins/safe-svg/"
23
+
24
+ #. Description of the plugin/theme
25
+ #:
26
+ msgid "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
27
+ msgstr "Позволяет SVG добавления в Wordpress и дезинфицирует SVG до его сохранения"
28
+
29
+ #. Author of the plugin/theme
30
+ #:
31
+ msgid "Daryll Doyle"
32
+ msgstr "Daryll Doyle"
33
+
34
+ #. Author URI of the plugin/theme
35
+ #:
36
+ msgid "http://enshrined.co.uk"
37
+ msgstr "http://enshrined.co.uk"
38
+
languages/safe-svg.pot ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2015 Safe SVG
2
+ # This file is distributed under the same license as the Safe SVG package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Safe SVG 1.0.0\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/safe-svg\n"
7
+ "POT-Creation-Date: 2015-07-04 12:31:03+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #: safe-svg.php:66
16
+ msgid ""
17
+ "Sorry, this file couldn't be sanitized so for security reasons wasn't "
18
+ "uploaded"
19
+ msgstr ""
20
+
21
+ #. Plugin Name of the plugin/theme
22
+ msgid "Safe SVG"
23
+ msgstr ""
24
+
25
+ #. Plugin URI of the plugin/theme
26
+ msgid "https://wordpress.org/plugins/safe-svg/"
27
+ msgstr ""
28
+
29
+ #. Description of the plugin/theme
30
+ msgid ""
31
+ "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it"
32
+ msgstr ""
33
+
34
+ #. Author of the plugin/theme
35
+ msgid "Daryll Doyle"
36
+ msgstr ""
37
+
38
+ #. Author URI of the plugin/theme
39
+ msgid "http://enshrined.co.uk"
40
+ msgstr ""
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Safe SVG ===
2
  Contributors: enshrined
3
  Donate link: http://enshrined.co.uk
4
- Tags: svg, sanitize, uploads, sanitise
5
  Requires at least: 4.0
6
- Tested up to: 4.2.2
7
- Stable tag: 1.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -27,4 +27,8 @@ Install through the WordPress directory or download, unzip and upload the files
27
  = 1.0.0 =
28
  * Initial Release
29
 
 
 
 
 
30
 
1
  === Safe SVG ===
2
  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.3
7
+ Stable tag: 1.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
27
  = 1.0.0 =
28
  * Initial Release
29
 
30
+ = 1.1.0 =
31
+ * Added i18n
32
+ * Added da, de ,en, es, fr, nl and ru translations
33
+ * Fixed an issue with filename not being pulled over on failed uploads
34
 
safe-svg.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
2
  /*
3
  Plugin Name: Safe SVG
4
- Plugin URI: http://wordpress.org/extend/plugins/health-check/
5
  Description: Allows SVG uploads into Wordpress and sanitizes the SVG before saving it
6
- Version: 1.0.0
7
  Author: Daryll Doyle
8
  Author URI: http://enshrined.co.uk
 
 
9
  */
10
 
11
  defined( 'ABSPATH' ) or die( 'Really?' );
@@ -14,81 +16,82 @@ require 'lib/vendor/autoload.php';
14
 
15
  if ( ! class_exists( 'safe_svg' ) ) {
16
 
17
- /**
18
- * Class safe_svg
19
- */
20
- Class safe_svg {
21
-
22
- /**
23
- * The sanitizer
24
- *
25
- * @var \enshrined\svgSanitize\Sanitizer
26
- */
27
- protected $sanitizer;
28
-
29
- /**
30
- * Set up the class
31
- */
32
- function __construct() {
33
- $this->sanitizer = new enshrined\svgSanitize\Sanitizer();
34
-
35
- add_filter( 'upload_mimes', array( $this, 'allow_svg' ) );
36
- add_filter( 'wp_handle_upload_prefilter', array( $this, 'check_for_svg' ) );
37
- }
38
-
39
- /**
40
- * Allow SVG Uploads
41
- *
42
- * @param $mimes
43
- *
44
- * @return mixed
45
- */
46
- public function allow_svg( $mimes ) {
47
- $mimes['svg'] = 'image/svg+xml';
48
-
49
- return $mimes;
50
- }
51
-
52
- /**
53
- * Check if the file is an SVG, if so handle appropriately
54
- *
55
- * @param $file
56
- *
57
- * @return mixed
58
- */
59
- public function check_for_svg( $file ) {
60
-
61
- if ( $file['type'] === 'image/svg+xml' ) {
62
- if ( ! $this->sanitize( $file['tmp_name'] ) ) {
63
- return array( 'error' => 'Sorry, this file couldn\'t be sanitized so for security reasons wasn\'t uploaded' );
64
- }
65
- }
66
-
67
- return $file;
68
- }
69
-
70
- /**
71
- * Sanitize the SVG
72
- *
73
- * @param $file
74
- *
75
- * @return bool|int
76
- */
77
- protected function sanitize( $file ) {
78
- $dirty = file_get_contents( $file );
79
-
80
- $clean = $this->sanitizer->sanitize( $dirty );
81
-
82
- if ( $clean === false ) {
83
- return false;
84
- }
85
-
86
- file_put_contents( $file, $clean );
87
-
88
- return true;
89
- }
90
-
91
- }
 
92
  }
93
 
94
  $safe_svg = new safe_svg();
1
  <?php
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.1.0
7
  Author: Daryll Doyle
8
  Author URI: http://enshrined.co.uk
9
+ Text Domain: safe-svg
10
+ Domain Path: /languages
11
  */
12
 
13
  defined( 'ABSPATH' ) or die( 'Really?' );
16
 
17
  if ( ! class_exists( 'safe_svg' ) ) {
18
 
19
+ /**
20
+ * Class safe_svg
21
+ */
22
+ Class safe_svg {
23
+
24
+ /**
25
+ * The sanitizer
26
+ *
27
+ * @var \enshrined\svgSanitize\Sanitizer
28
+ */
29
+ protected $sanitizer;
30
+
31
+ /**
32
+ * Set up the class
33
+ */
34
+ function __construct() {
35
+ $this->sanitizer = new enshrined\svgSanitize\Sanitizer();
36
+
37
+ add_filter( 'upload_mimes', array( $this, 'allow_svg' ) );
38
+ add_filter( 'wp_handle_upload_prefilter', array( $this, 'check_for_svg' ) );
39
+ }
40
+
41
+ /**
42
+ * Allow SVG Uploads
43
+ *
44
+ * @param $mimes
45
+ *
46
+ * @return mixed
47
+ */
48
+ public function allow_svg( $mimes ) {
49
+ $mimes['svg'] = 'image/svg+xml';
50
+
51
+ return $mimes;
52
+ }
53
+
54
+ /**
55
+ * Check if the file is an SVG, if so handle appropriately
56
+ *
57
+ * @param $file
58
+ *
59
+ * @return mixed
60
+ */
61
+ public function check_for_svg( $file ) {
62
+
63
+ if ( $file['type'] === 'image/svg+xml' ) {
64
+ if ( ! $this->sanitize( $file['tmp_name'] ) ) {
65
+ $file['error'] = __( "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded",
66
+ 'safe-svg' );
67
+ }
68
+ }
69
+
70
+ return $file;
71
+ }
72
+
73
+ /**
74
+ * Sanitize the SVG
75
+ *
76
+ * @param $file
77
+ *
78
+ * @return bool|int
79
+ */
80
+ protected function sanitize( $file ) {
81
+ $dirty = file_get_contents( $file );
82
+
83
+ $clean = $this->sanitizer->sanitize( $dirty );
84
+
85
+ if ( $clean === false ) {
86
+ return false;
87
+ }
88
+
89
+ file_put_contents( $file, $clean );
90
+
91
+ return true;
92
+ }
93
+
94
+ }
95
  }
96
 
97
  $safe_svg = new safe_svg();