[PHP8?] functions_metadata.inc.php Fatal error strip_tags() #1452

Open
opened 2026-10-05 00:44:25 +02:00 by adam · 0 comments
Owner

I'm not sure if this is PHP8 related but I got this message:

Fatal error: Uncaught TypeError: strip_tags(): Argument #1 ($string) must be of type string, array given in /xxx/include/functions_metadata.inc.php:190 Stack trace: #0 /xxx/include/functions_metadata.inc.php(190): strip_tags() #1 /xxx/include/picture_metadata.inc.php(24): get_exif_data() #2 /xxx/picture.php(1017): include('...') #3 {main} thrown in /xxx/include/functions_metadata.inc.php on line 190

In the functions_metadata.inc.php on line 190 (as mentioned above) I disabled the strip_tags($value); and I do not get the error message anymore. The error prevents the page to be displayed, especially with reading Exif (like in Bootstrap Darkroom etc) for the picture/photo page.

if (!$conf['allow_html_in_metadata'])
{
foreach ($result as $key => $value)
{
// in case the origin of the photo is unsecure (user upload), we remove
// HTML tags to avoid XSS (malicious execution of javascript)
//$result[$key] = strip_tags($value);
}
}

See also on the forum -> https://piwigo.org/forum/viewtopic.php?pid=183718#p183718

BTW ... PHP says about strip_tags(): This function should not be used to try to prevent XSS attacks. Use more appropriate functions like htmlspecialchars() or other means depending on the context of the output.

Environment:
Piwigo 12.2.0
Operating system: Linux
PHP: 8.0.8 (Show info) [2022-05-12 13:00:07]
MySQL: 8.0.29-0ubuntu0.21.10.2 [2022-05-12 13:00:07]
Graphics Library: ImageMagick 6.9.11-60

I'm not sure if this is PHP8 related but I got this message: Fatal error: Uncaught TypeError: strip_tags(): Argument #1 ($string) must be of type string, array given in /xxx/include/functions_metadata.inc.php:190 Stack trace: #0 /xxx/include/functions_metadata.inc.php(190): strip_tags() #1 /xxx/include/picture_metadata.inc.php(24): get_exif_data() #2 /xxx/picture.php(1017): include('...') #3 {main} thrown in /xxx/include/functions_metadata.inc.php on line 190 In the functions_metadata.inc.php on line 190 (as mentioned above) I disabled the strip_tags($value); and I do not get the error message anymore. The error prevents the page to be displayed, especially with reading Exif (like in Bootstrap Darkroom etc) for the picture/photo page. if (!$conf['allow_html_in_metadata']) { foreach ($result as $key => $value) { // in case the origin of the photo is unsecure (user upload), we remove // HTML tags to avoid XSS (malicious execution of javascript) **//$result[$key] = strip_tags($value);** } } See also on the forum -> https://piwigo.org/forum/viewtopic.php?pid=183718#p183718 BTW ... PHP says about strip_tags(): This function should not be used to try to prevent XSS attacks. Use more appropriate functions like htmlspecialchars() or other means depending on the context of the output. Environment: Piwigo 12.2.0 Operating system: Linux PHP: 8.0.8 (Show info) [2022-05-12 13:00:07] MySQL: 8.0.29-0ubuntu0.21.10.2 [2022-05-12 13:00:07] Graphics Library: ImageMagick 6.9.11-60 <!-- github-sync-id:1233823348 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1452