Re: get_field() and + symbol

Mario Ruggier <[email protected]> Wed, 14 Feb 2007 15:46:58 +0100
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
Quoting Arturo FM <[email protected]>:

> Hi!
> I have a litte problem with the '+' symbol. I use an
> AJAX call to send data from JavaScript code to Quixote
> code but get_field() function dont' receive a correct
> value.
>
> The code in JavaScript:
>
> {..}
> http.open('POST', 'buscar_ficha', true);
> http.setRequestHeader('Content-Type',
> 'application/x-www-form-urlencoded');
> http.onreadystatechange = handleResponse;
>
> busca_val_enc = escape(busca_val);
>
> params = "&sel_busca=" + selBusca + "&busca_val=" +
> busca_val_enc;
>
> http.send(params);
> {..}
>
> For example, I send 'hello +' like the 'busca_val'
> param and I get only 'hello' the '+' seems to
> dissapear.
>
> In my Quixote application:
>
> {..}
> pub = get_publisher()
> field = get_field('sel_busca')
> value = get_field('busca_val')
>
> print value
> {..}
>
> It's print only 'hello' but I need 'hello +'.

I have seen mention in some places that javascript's escape() misses single and
double quotes, the / and + characters... !!

What is escape() returning, on the client?

If the + is unescaped, you could try something like:
escape(str).replace(/\+/g, '%2B')

Another point, have you tried doing same with GET, and appending the params as
querystring to your URL? With POST, your are sending the params as content,
that should be encoded as per your content-type -- not sure if escape() is what
should be used for this.

Have you checked what the server side HTTP request is receiving as raw form
data?

mario