[impressum] Avoid calling obfuscate_email on a null value
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Jan 2023 14:09:59 +0000 (09:09 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Jan 2023 14:09:59 +0000 (09:09 -0500)
- Address https://github.com/friendica/friendica/issues/12486#issuecomment-1378416688

impressum/impressum.php

index d7298cb..52c91de 100644 (file)
@@ -61,31 +61,30 @@ function impressum_load_config(App $a, ConfigFileManager $loader)
 
 function impressum_show(App $a, string &$body)
 {
-       $body .= '<h3>' . DI::l10n()->t('Impressum') . '</h3>';
-       $owner = DI::config()->get('impressum', 'owner');
+       $body          .= '<h3>' . DI::l10n()->t('Impressum') . '</h3>';
+       $owner         = DI::config()->get('impressum', 'owner');
        $owner_profile = DI::config()->get('impressum', 'ownerprofile');
-       $postal = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'postal')));
-       $notes = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'notes')));
-       $email = obfuscate_email( DI::config()->get('impressum', 'email') );
+       $postal        = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'postal')));
+       $notes         = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'notes')));
 
-       if (strlen($owner)) {
-               if (strlen($owner_profile)) {
+       if ($owner) {
+               if ($owner_profile) {
                        $tmp = '<a href="' . $owner_profile . '">' . $owner . '</a>';
                } else {
                        $tmp = $owner;
                }
 
-               if (strlen($email)) {
-                       $body .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'<br /><strong>' . DI::l10n()->t('Email Address') . '</strong>: ' . $email . '</p>';
+               if ($email = DI::config()->get('impressum', 'email')) {
+                       $body .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'<br /><strong>' . DI::l10n()->t('Email Address') . '</strong>: ' . obfuscate_email($email) . '</p>';
                } else {
                        $body .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'</p>';
                }
 
-               if (strlen($postal)) {
+               if ($postal) {
                        $body .= '<p><strong>' . DI::l10n()->t('Postal Address') . '</strong><br />' . $postal . '</p>';
                }
 
-               if (strlen($notes)) {
+               if ($notes) {
                        $body .= '<p>' . $notes . '</p>';
                }
        } else {