Committer: nnikulochkina
LJSUP-13487: XMLRPC getfriendspage: error on parse lj-user with nonexistent usernameU trunk/cgi-bin/ljtextutil.pl
Modified: trunk/cgi-bin/ljtextutil.pl =================================================================== --- trunk/cgi-bin/ljtextutil.pl 2012-08-30 13:06:06 UTC (rev 22782) +++ trunk/cgi-bin/ljtextutil.pl 2012-08-31 07:44:24 UTC (rev 22783) @@ -872,13 +872,16 @@ while ( $args{event} =~ /<lj\s+user="([^>"]+)"\s*\/?>/g ){ # follow the documentation - no about communites, openid or syndicated, just user my $username = $1; - my $user = LJ::load_user($username); - # $username may be not equal to $name (if $username is not canonical username) - my $name = $user->username; - my $html = '<a href="' . $user->profile_url . '" target="_blank"><img src="' - . $LJ::IMGPREFIX . '/userinfo.gif?v=17080" alt=""></a><a href="' - . $user->journal_base . '" target="_blank">' . $name . '</a>'; - $args{event} =~ s#<lj\s+user="$username"\s*\/?>#$html#g; + if (my $user = LJ::load_user($username)) { + # $username may be not equal to $name (if $username is not canonical username) + my $name = $user->username; + my $html = '<a href="' . $user->profile_url . '" target="_blank"><img src="' + . $LJ::IMGPREFIX . '/userinfo.gif?v=17080" alt=""></a><a href="' + . $user->journal_base . '" target="_blank">' . $name . '</a>'; + $args{event} =~ s#<lj\s+user="$username"\s*\/?>#$html#g; + } else { + $args{event} =~ s#<lj\s+user="$username"\s*\/?>#$username#g; + } } $args{event} =~ s#</?lj-cut[^>]*>##g;