Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

search - error with leading space

Quote Reply
search - error with leading space
entering a query with only spaces will result in a server error.

entering a query with a leading space will alter all special characters in the result provided by link.html into their html-aliases e.g.: ä is shown as & a u m l ; (without the spaces between the chars)

is there a solution for these problems?

Quote Reply
Re: search - error with leading space In reply to
Try using the search-ni.cgi...Also blanks in queries have been discussed before in this forum.

Regards,

Eliot

Quote Reply
Re: search - error with leading space In reply to
why should i change to the slower search-script?

wouldn't it be better to change the current script to remove the bug?

btw.: this error also appears on the demo search for links-sql on this site: just enter one blank and search!


Quote Reply
Re: search - error with leading space In reply to
At the top of search.cgi after it gets the query parameter, change:

Code:
sub main {
# ---------------------------------------------------
# Determine what to do.
#
my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;
print $in->header();

my $check_query = $in->param('query'); ## put query term in modifiable variable.
$check_query =~ s/^\s+//; ## remove leading spaces

if ($check_query) {
&search ($in, $dynamic);
}
else {
&site_html_search_form ( { query => '' }, $dynamic );
}
}
That should catch a "blank" query.

In order to catch the leading spaces problem, you'd need to do the same check in the search procedure where query is processed:

Code:
# Split up the search term.
$query = $in->param('query');
add the following:

$query =~ s/^\s+//; ## remove leading spaces

That will catch the string that contains non-space characters, but has spaces at the leading edge.




http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: search - error with leading space In reply to
yes, that's the thing i needed - thanks pugdog!