--- loncom/lonnet/perl/lonnet.pm 2007/09/05 17:37:51 1.910 +++ loncom/lonnet/perl/lonnet.pm 2007/09/12 03:40:35 1.911 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.910 2007/09/05 17:37:51 albertel Exp $ +# $Id: lonnet.pm,v 1.911 2007/09/12 03:40:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -906,8 +906,8 @@ sub usersearch { if (&host_domain($tryserver) eq $dom) { my $host=&hostname($tryserver); my $queryid= - &reply("querysend:".&escape($query).':'.&escape($dom).':'. - &escape($srch->{'srchby'}).'%%'. + &reply("querysend:".&escape($query).':'. + &escape($srch->{'srchby'}).':'. &escape($srch->{'srchtype'}).':'. &escape($srch->{'srchterm'}),$tryserver); if ($queryid !~/^\Q$host\E\_/) { @@ -924,20 +924,23 @@ sub usersearch { if ( ($reply =~/^timeout/) || ($reply =~/^error/) ) { &logthis('usersrch error: '.$reply.' for '.$dom.' - searching for : '.$srch->{'srchterm'}.' by '.$srch->{'srchby'}.' ('.$srch->{'srchtype'}.') - maxtries: '.$maxtries.' tries: '.$tries); } else { - my @matches = split(/&/,$reply); + my @matches; + if ($reply =~ /\n/) { + @matches = split(/\n/,$reply); + } else { + @matches = split(/\&/,$reply); + } foreach my $match (@matches) { - my @items = split(/:/,$match); my ($uname,$udom,%userhash); - foreach my $entry (@items) { - my ($key,$value) = split(/=/,$entry); - $key = &unescape($key); - $value = &unescape($value); + foreach my $entry (split(/:/,$match)) { + my ($key,$value) = + map {&unescape($_);} split(/=/,$entry); $userhash{$key} = $value; if ($key eq 'username') { $uname = $value; } elsif ($key eq 'domain') { $udom = $value; - } + } } $results{$uname.':'.$udom} = \%userhash; }