From 777454f0b9980f90caa518ea24f7eaa991ed6a79 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Fri, 5 Dec 2014 15:03:46 +0100 Subject: managed "uninitialized value" --- lib/AdminPanel/Rpmdragora/formatting.pm | 20 ++++++++++++-------- lib/AdminPanel/Rpmdragora/gui.pm | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/AdminPanel/Rpmdragora/formatting.pm b/lib/AdminPanel/Rpmdragora/formatting.pm index b484455..c096c5f 100644 --- a/lib/AdminPanel/Rpmdragora/formatting.pm +++ b/lib/AdminPanel/Rpmdragora/formatting.pm @@ -58,6 +58,8 @@ my $loc = AdminPanel::rpmdragora::locale(); sub escape_text_for_TextView_markup_format { my ($str) = @_; + return '?-?-?' unless ref $str; + my %rules = ('&' => '&', '<' => '<', '>' => '>', @@ -71,20 +73,22 @@ sub escape_text_for_TextView_markup_format { # from rpmtools, #37482: sub ensure_utf8 { - if (utf8::is_utf8($_[0])) { - utf8::valid($_[0]) and return; + return '?-?-?' unless ref $_[0]; - utf8::encode($_[0]); #- disable utf8 flag - utf8::upgrade($_[0]); + if (utf8::is_utf8($_[0])) { + utf8::valid($_[0]) and return; + utf8::encode($_[0]); #- disable utf8 flag + utf8::upgrade($_[0]); } else { - utf8::decode($_[0]); #- try to set utf8 flag - utf8::valid($_[0]) and return; - warn "do not know what to with $_[0]\n"; + utf8::decode($_[0]); #- try to set utf8 flag + utf8::valid($_[0]) and return; + warn "do not know what to with $_[0]\n"; } } sub rpm_description { my ($description) = @_; + return '?-?-?' unless ref $description; ensure_utf8($description); my $t = ""; @@ -166,7 +170,7 @@ sub format_changelog_changelogs { sub format_update_field { my ($name) = @_; - '' . eval { escape_text_for_TextView_markup_format($name) } . ''; + '' . escape_text_for_TextView_markup_format($name) . ''; } sub format_name_n_summary { diff --git a/lib/AdminPanel/Rpmdragora/gui.pm b/lib/AdminPanel/Rpmdragora/gui.pm index 6fe64dc..926783b 100644 --- a/lib/AdminPanel/Rpmdragora/gui.pm +++ b/lib/AdminPanel/Rpmdragora/gui.pm @@ -194,7 +194,7 @@ sub get_main_text { my ($medium, $fullname, $name, $summary, $is_update, $update_descr) = @_; my $txt = get_string_from_keywords($medium, $fullname); - my $notice = MDK::Common::Func::if_($txt, format_field($loc->N("Notice: ")) . $txt . "\n"); + my $notice = MDK::Common::Func::if_($txt, format_field($loc->N("Notice: ")) . $txt . "\n") || ""; ensure_utf8($notice); my $hdr = format_header(join(' - ', $name, $summary)) . "\n"; @@ -203,7 +203,7 @@ sub get_main_text { my $update = MDK::Common::Func::if_($is_update, # is it an update? format_field($loc->N("Importance: ")) . format_update_field($update_descr->{importance}) . "\n", format_field($loc->N("Reason for update: ")) . format_update_field(rpm_description($update_descr->{pre})) . "\n", - ); + ) || ""; ensure_utf8($update); # TODO Too many lines -- cgit v1.2.1