Implement Settings > Media's "Allow SVG uploads" toggle (v2.3.0)

The toggle existed in the UI with no implementation behind it, so
uploads were rejected regardless of the setting. New SvgUploads class:
- Allowlists the SVG mime type and fixes WP's real-mime sniff, which
  otherwise nulls out the file type for SVGs specifically even after
  the mime allowlist is updated.
- Populates width/height metadata (parsed from the SVG's own
  viewBox/width/height) — without this, wp_get_missing_image_subsizes()
  throws undefined-array-key warnings that can corrupt the upload
  response's JSON on environments with warnings displayed inline.
- Basic sanitization on upload (strips <script> tags, inline event
  handlers, javascript: URIs).

Verified live via the REST media endpoint: clean upload with correct
dimensions, and a malicious test SVG had its script/handlers stripped
while staying valid markup.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
nixpanel
2026-07-04 07:46:56 -05:00
co-authored by Claude Sonnet 5
parent 077e9b8d3c
commit 39af8d650d
5 changed files with 168 additions and 3 deletions
+3 -2
View File
@@ -3,7 +3,7 @@
* Plugin Name: Aurora Admin
* Plugin URI: https://aurora.co
* Description: A modern, fast WordPress admin interface.
* Version: 2.2.0
* Version: 2.3.0
* Author: Aurora
* Text Domain: aurora-admin
* Domain Path: /languages/
@@ -14,7 +14,7 @@
defined("ABSPATH") || exit();
define("AURORA_ADMIN_VERSION", "2.2.0");
define("AURORA_ADMIN_VERSION", "2.3.0");
define("AURORA_ADMIN_PATH", plugin_dir_path(__FILE__));
define("AURORA_ADMIN_URL", plugins_url("aurora-admin/"));
@@ -44,5 +44,6 @@ require AURORA_ADMIN_PATH . "admin/src/ActivityLog/ActivityLog.php";
require AURORA_ADMIN_PATH . "admin/src/ActivityLog/ActivityLogData.php";
require AURORA_ADMIN_PATH . "admin/src/DatabaseExplorer/DatabaseExplorerData.php";
require AURORA_ADMIN_PATH . "admin/src/Login/LoginStyle.php";
require AURORA_ADMIN_PATH . "admin/src/Media/SvgUploads.php";
new AuroraAdmin\App\AuroraAdmin();