From 9b6ee65925d9c78f66d072bba4f68fbb9b9ed747 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 11 Nov 2008 23:14:14 -0700 Subject: [PATCH] Determine fallback filename. --- framework/Mime/lib/Horde/Mime/Viewer/rar.php | 10 ++++++++-- framework/Mime/lib/Horde/Mime/Viewer/tgz.php | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/rar.php b/framework/Mime/lib/Horde/Mime/Viewer/rar.php index ed173d325..96751eab3 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/rar.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/rar.php @@ -60,9 +60,15 @@ class Horde_Mime_Viewer_rar extends Horde_Mime_Viewer_Driver require_once 'Horde/Text.php'; - $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $this->_mimepart->getName(true))) . ':' . "\n" . + $name = $this->_mimepart->getName(true); + if (empty($name)) { + $name = _("unnamed"); + } + + + $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . '
' . - Text::htmlAllSpaces(_("Archive Name") . ': ' . $this->_mimepart->getName(true)) . "\n" . + Text::htmlAllSpaces(_("Archive Name") . ': ' . $name) . "\n" . Text::htmlAllSpaces(_("Archive File Size") . ': ' . strlen($contents) . ' bytes') . "\n" . Text::htmlAllSpaces(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount)) . "\n\n" . diff --git a/framework/Mime/lib/Horde/Mime/Viewer/tgz.php b/framework/Mime/lib/Horde/Mime/Viewer/tgz.php index 3fc6c9480..4c8d5c63a 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/tgz.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/tgz.php @@ -78,9 +78,14 @@ class Horde_Mime_Viewer_tgz extends Horde_Mime_Viewer_Driver require_once 'Horde/Text.php'; - $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $this->_mimepart->getName(true))) . ':' . "\n" . + $name = $this->_mimepart->getName(true); + if (empty($name)) { + $name = _("unnamed"); + } + + $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . '
' . - Text::htmlAllSpaces(_("Archive Name") . ': ' . $this->_mimepart->getName(true)) . "\n" . + Text::htmlAllSpaces(_("Archive Name") . ': ' . $name) . "\n" . Text::htmlAllSpaces(_("Archive File Size") . ': ' . strlen($contents) . ' bytes') . "\n" . Text::htmlAllSpaces(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount)) . "\n\n" . -- 2.11.0