Skip to content

[6.2] Detailed Error-Message when upload of SVG-Files is not possible #3807

Description

@jgerman-bot

New language relevant PR in upstream repo: joomla/joomla-cms#48204 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/language/en-GB/lib_joomla.ini b/administrator/language/en-GB/lib_joomla.ini
index e955da5226c69..cbb1f370ea2de 100644
--- a/administrator/language/en-GB/lib_joomla.ini
+++ b/administrator/language/en-GB/lib_joomla.ini
@@ -709,6 +709,8 @@ JLIB_MAIL_FUNCTION_DISABLED="The mail() function has been disabled and the mail
 JLIB_MAIL_FUNCTION_OFFLINE="The mail function has been disabled by an administrator."
 JLIB_MAIL_INVALID_EMAIL_SENDER="Invalid email sender: %s"
 
+JLIB_MEDIA_ERROR_SVG_ISSUE="SVG Issue: %s"
+JLIB_MEDIA_ERROR_SVG_UNKNOWN="Unknown SVG error"
 JLIB_MEDIA_ERROR_UPLOAD_INPUT="Unable to upload file."
 JLIB_MEDIA_ERROR_WARNFILENAME="File name must only have alphanumeric characters and no spaces."
 JLIB_MEDIA_ERROR_WARNFILETOOLARGE="This file is too large to upload. You can change the limits for your site in the component options."
diff --git a/language/en-GB/lib_joomla.ini b/language/en-GB/lib_joomla.ini
index ce6e39e4516ba..105557192ced8 100644
--- a/language/en-GB/lib_joomla.ini
+++ b/language/en-GB/lib_joomla.ini
@@ -695,6 +695,8 @@ JLIB_MAIL_FUNCTION_DISABLED="The mail() function has been disabled and the mail
 JLIB_MAIL_FUNCTION_OFFLINE="The mail function has been disabled by an administrator."
 JLIB_MAIL_INVALID_EMAIL_SENDER="Invalid email sender: %s"
 
+JLIB_MEDIA_ERROR_SVG_ISSUE="SVG Issue: %s"
+JLIB_MEDIA_ERROR_SVG_UNKNOWN="Unknown SVG error"
 JLIB_MEDIA_ERROR_UPLOAD_INPUT="Unable to upload file."
 JLIB_MEDIA_ERROR_WARNFILENAME="File name must only have alphanumeric characters and no spaces."
 JLIB_MEDIA_ERROR_WARNFILETOOLARGE="This file is too large to upload."
diff --git a/libraries/src/Helper/MediaHelper.php b/libraries/src/Helper/MediaHelper.php
index 623b8e5976851..00f8893c29e68 100644
--- a/libraries/src/Helper/MediaHelper.php
+++ b/libraries/src/Helper/MediaHelper.php
@@ -519,7 +519,22 @@ private static function isValidSvg($file, $shouldLogErrors = true): bool
 
         if ($isValid === false || \count($svgErrors)) {
             if ($shouldLogErrors) {
-                Factory::getApplication()->enqueueMessage(Text::_('JLIB_MEDIA_ERROR_WARNIEXSS'), 'error');
+                $messages = [];
+
+                foreach ($svgErrors as $error) {
+                    $messages[] = Text::sprintf(
+                        'JLIB_MEDIA_ERROR_SVG_ISSUE',
+                        htmlspecialchars($error['message'] ?? Text::_('JLIB_MEDIA_ERROR_SVG_UNKNOWN'), ENT_QUOTES, 'UTF-8')
+                    );
+                }
+
+                $messageText = Text::_('JLIB_MEDIA_ERROR_WARNIEXSS');
+
+                if (!empty($messages)) {
+                    $messageText .= '<br>' . implode('<br>', $messages);
+                }
+
+                Factory::getApplication()->enqueueMessage($messageText, 'error');
             }
 
             return false;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions