"& lang" is misinterpreted in the url

I am developing for javascript disabled phones. My code is as follows:

<a href="someurl?var=a&lang=english">Link 1</a>
<a href="someurl?lang=english&var=a">Link 2</a>

But the browser interprets the URL as -

someurl?var=a%e2%8c%a9=english         (Link 1, incorrect)
someurl?lang=english&var=a             (Link 2 works just fine !)

It seems to &lang=englishconvert toa%e2%8c%a9=english

Can anyone explain why this is happening?

+4
source share
3 answers

In HTML, a symbol &represents the beginning of a symbol reference.

If you try to specify an invalid character reference, then browsers will perform error recovery and instead treat it as an ampersand.

From HTML DTD:

<!ENTITY lang     CDATA "&#9001;" -- left-pointing angle bracket = bra,
                                 U+2329 ISOtech -->

... &lang .

, : &amp;

+7

HTML 4.01, &lang U + 2329 LEFT-POINTING ANGLE BRACKET "<". UTF-8 0xE2 0x8C 0xA9, URL- % - a%e2%8c%a9.

. , URL- &lang , = ( HTML 4.01).

, , HTML, "&" &amp; - "&" , .

, URL-, , ";" "&" .

+4

http://www.htmlhelp.com/tools/validator/problems.html#amp ( w3 http://validator.w3.org/docs/help.html) .

& entity. , , &euro; (€), &lt; (<),..

If you now specify the URL &lang, this causes an error in any validator, because it is not a valid object. After that, the browser will avoid this sequence.

Decision:

You have to avoid &your own essence: &amp;for the URL to look like this:

<a href="someurl?var=a&amp;lang=english">Link 1</a>
+3
source

Source: https://habr.com/ru/post/1540213/


All Articles