Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How-to XHTML 1.1 validate an ampersand without escaping it?

My issue is the following. I have a XHTML 1.1 page that has a form and input fields. One of the input fields contains a value which is an URI. This URI contains key-value pairs with ampersand (&) as argument separator, that will be passed as a GET request by another web application in the browser.

Usually I would use the entity & to create the ampersands to validate the code as XHTML 1.1. My problem here is that the application does not receive the GET request, since (as expected) the browser does not understand how to handle & in the URI.

So my question is really how to write an ampersand without using the HTML entity, so the browser still recognises it as the argument separator and the GET request is passed on properly to the web app.

I tried Hex (%26) encoding the ampersand but the browser still does not "translate" it back to a proper & character.

A related question, but it does not provide the exact answer to the question I am asking:

XHTML and & (Ampersand) encoding

like image 488
mr-euro Avatar asked Oct 25 '22 22:10

mr-euro


1 Answers

There is no way to include an ampersand character in an attribute value without using an entity.

There is no way to include an ampersand character as a textNode without using an entity or CDATA markers (but I bet you are serving as text/html so you can't use those).

That said — any browser which fails to decode the entity is broken. No mainstream browser fails there. You are either using an obscure and broken browser, or are misdiagnosing the problem.

like image 174
Quentin Avatar answered Nov 14 '22 18:11

Quentin