unwanted amp injected in url

Hi all,

<%=link_to_remote "A", :url => attendee_path(:id => 1 , :event_id => event.id, :present => '1') %> results in <a href="#" onclick="new Ajax.Request('/attendees?present=1&amp;event_id=61', {asynchronous:true, evalScripts:true}); return false;">A</a>. For some reason amp; appears in the url.

Someone knows why this happenes?

Thanks in advance Stijn

Missing route?

it's not a rotring problem. The route is generated as it should be. It just injects amps; in the url.

I actually guess this is a bug but someone must have seen this before, no?

Stijn

It's not a bug. This is how you're supposed to encode ampersands in HTML. Even in URLs which are part of tag attributes.

Chris

The thing is that I don't want to encode ampersands and have no idea where they come from. i only insert ids in the url andit seems that rails adds amp; to them.

Stijn

Many thanks for all the replies. Still got some questions though

When I examine (with a debugger) the 'present' parameter that get send via the 'ampersanded' url I see it calls them 'amp;present' and not 'present' as I want it to be called (and as defined in the model). Is there a way I can remove this amp; drom 'present'.

About XHTML compliant: When I do a querry with Google test - Google Search… I dont' see the amp; s in the url. Isn't Google XHTML compliant or am I missing the point completely

Stijn

No, google's pages aren't valid XHTML, or even valid HTML 4.01. Google doesn't specify a doctype in their results pages, but when I tried validating a results page against HTML 4.01 I got around 240 errors.

Ampersands are used in XHTML to indicate an entity that needs to be translated, so they can't be used on their own. That applies just as much in entities (hrefs for links, image srcs, etc) as it does in text. They have to be escaped to be &amp;

There's a lot of discussion of that online. Two I found quickly are:

http://www.mezzoblue.com/archives/2003/02/17/urls_vs_xhtm/ http://annevankesteren.nl/2004/06/ampersands-matter

James.