--- Schema.pm.orig 2011-08-15 14:55:40.000000000 +0100 +++ Schema.pm 2012-01-15 17:35:38.000000000 +0000 @@ -37,6 +37,7 @@ use Storable; use Tie::Cache::LRU::Expires; use URI; +use Encode qw(encode decode); use Slim::Formats; use Slim::Player::ProtocolHandlers; @@ -2538,8 +2539,20 @@ for my $c ( @{$rawcomments} ) { next unless defined $c; - # Bug 15630, ignore strings which have the utf8 flag on but are in fact invalid utf8 - next if utf8::is_utf8($c) && !Slim::Utils::Unicode::looks_like_utf8($c); + # Bug 15630, 17863. Sanitize strings which have the utf8 flag on but are in fact invalid utf8 + if (utf8::is_utf8($c)) { + # Round trips the potentially invalid string, eliminating malformed characters + + # encode("utf8", $c) regenerates the original octets, and should always succeed + # decode("UTF-8",$octets,Encode::FB_DEFAULT) generates a valid string, replacing any malformed + # characters with a substitution character. + + $c = decode("UTF-8",encode("utf8", $c),Encode::FB_DEFAULT); + + } else { + # for completeness, attempts to catch case should string contain non-ascii octets. + $c = Slim::Utils::Unicode::utf8decode($c); + } #ignore SoundJam and iTunes CDDB comments, iTunSMPB, iTunPGAP if ($c =~ /SoundJam_CDDB_/ ||