开发者

Param value truncates at first space (rest of URL gone)

开发者 https://www.devze.com 2023-03-17 14:59 出处:网络
Problem I have an html form and a perl cgi.pm script. A search is entered into a text field. If there is a space in the entry, any other parameters(like selected radio buttons) are cut off. ex. \'hell

Problem

I have an html form and a perl cgi.pm script.

A search is entered into a text field. If there is a space in the entry, any other parameters(like selected radio buttons) are cut off. ex. 'hello world', results in only 'hello'.

So the url has the value: query=hello instead of query=hello+world&name=tag&name1=tag1....

The call in the perl script is: $search_key = param('query') does not contain the space or anything after it. $search_key = 'hello' only.

Confusion

It works fine when I use my own web server, apache, at localhost. But the problem arises when trying to put it online. The only differences in code are: (1)the url hyperlinks in the perl script - search2011.cgi vs. multwordsearch.cgi (Not an issue), (2)an intermediate loading page - loading.cgi, and (3)the url in the "action=" call in the HTML code:

Working: <form name="search_option" action="http://localhost/cgi-bin/multiwordsearch.cgi" method="get" onSubmit="return checkform(this);">

vs.

Non-working:

<form name="search_option" action="/cgi-bin/loading.cgi" method="post" onSubmit="return checkform(this);">
        <h2><font color=forestgreen>Biomimetic Search</font></h2>
        <input type="text" name="query" size="40" />

Also Despite having "POST" it is still displaying query=hello!

I've tried the http... before /cgi-bin/, it did nothing. I tried $search_key =~ s/ /+/ but it didn't do anything, so I know the space doesn't get that far. Also, the hyperlinks work correctly (ie. the whole URL: all name-value tags are printed after the query). I've tried increasing the size of the text.

If the search is 'hello+world' it works as it should, so the problem is something isn't interpreting the space correctly.

Question

The problem is it truncates 开发者_C百科when coming from the form, either when the button is pressed, or just from the text field (or somewhere in cgi.pm).

Could this be a problem on my end? I realize there is limited info, but this is all that is different! Any ideas of what else to try?

Let me know if there is anything else you need.


I think the problem is your intermedia page which you discounted. The one which worked was multiwordsearch.cgi and the one which doesn't work is loading.cgi. So I assume loading.cgi is the intermediate page.

This will definitely be what is causing the problem. I assume it is getting the params and then redirecting to multiwordsearch.cgi. This explains why your POSTed parameters to loading.cgi are ending up on the query string of multiwordsearch.cgi. So it obviously has a bug when building the redirect URL.

So I suggest you look at the URL building code in loading.cgi. Or post it here if you need help.

0

精彩评论

暂无评论...
验证码 换一张
取 消