Form won't accept ampersand

Hi guys,

My start_form_tag generated form will not accept a text field containing
an ampersand.

For example, the text ‘A & B’ is trunacted to ‘A’ in the param hash.

I know ampersands have to be encoded in URLs, but I’m surprised my form
has a problem with this. I’ve tested this in Safari and Firefox.

thanks
Lindsay

It turns out start_form_tag isn’t the issue…

I’ve traced the problem down to an observe_field. The value being sent
by the AJAX call is 'A ’ - the ‘&B’ isn’t sent, as one would expect. So,
how can I escape the value to send the ‘&’ as an ‘&’? I’ve tried
‘:method => post’ but that doesn’t help either.

Lindsay

I know that the function h(string) strips a string and converts all
escape characters into their html-code equivalents.
so:
h “A & B”
will return “A & B”
or
h “A < B”
returns “A < B”

I hope this helps, it’s one of the few things I know!

Sebastian Wolf

On Feb 6, 3:55 pm, Lindsay B. [email protected]

Hi Lindsay,

Hi Lindsay,

Lindsay B. wrote:

how can I escape the value to send the ‘&’
as an ‘&’?

The problem, in general terms, is about accepting non-text input from
users.
It’s dangerous. Here’s a link to get you started.

hth,
Bill