PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.1
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
← All changes | includes/admin.php +17 -0 2.11.02.13.1 View file →
@@ -10,8 +10,9 @@
10 10 $self = new self();
11 11 $self->dispatch_hooks();
12 12
13 13 add_filter( 'upload_mimes', [ $self, 'allow_lottie_json_uploads' ] );
14 + add_filter( 'upload_mimes', [ $self, 'allow_svg_uploads' ] );
14 15 add_filter( 'wp_check_filetype_and_ext', function ( $data, $file, $filename ) {
15 16 $ext = pathinfo( $filename, PATHINFO_EXTENSION );
16 17
17 18 if ( 'json' === $ext ) {
@@ -16,8 +17,11 @@
16 17
17 18 if ( 'json' === $ext ) {
18 19 $data['ext'] = 'json';
19 20 $data['type'] = 'application/json';
21 + } elseif ( 'svg' === strtolower( $ext ) && current_user_can( 'unfiltered_html' ) ) {
22 + $data['ext'] = 'svg';
23 + $data['type'] = 'image/svg+xml';
20 24 }
21 25
22 26 return $data;
23 27 }, 10, 3 );
@@ -25,8 +29,21 @@
25 29
26 30 function allow_lottie_json_uploads( $mimes ) {
27 31 $mimes['json'] = 'application/json';
28 32 $mimes['lottie'] = 'application/json';
33 + return $mimes;
34 + }
35 +
36 + // Gated to unfiltered_html (administrators, by default) rather than opened
37 + // for every role: an SVG file can carry a <script>, and unlike the Atomic
38 + // SVG block's own read path (which strips scripts/handlers before inlining
39 + // markup — see atomic-svg/edit.js `cleanSvg`), the raw file the media
40 + // library stores is unsanitised and can execute if it is ever opened
41 + // directly as a top-level document.
42 + function allow_svg_uploads( $mimes ) {
43 + if ( current_user_can( 'unfiltered_html' ) ) {
44 + $mimes['svg'] = 'image/svg+xml';
45 + }
29 46 return $mimes;
30 47 }
31 48
32 49 public function dispatch_hooks() {