📜 ⬆️ ⬇️

Stop snooping around my browser.

With an enviable periodicity in the blog of the developers of the Opera browser, messages appear that Opera cannot parse one or another page and the user sees an error like this:



The effect can be viewed on any of these links . At the same time, in other popular browsers, pages are displayed normally, as well as in Opera, if you ask to parse the document as HTML, and not as XML (the link “Reparse document as HTML”).
')
At some point, I wondered why this was happening. There are not many options, or Opera cannot parse XML, which other browsers can parse, or other browsers do not try to parse pages as XML, but consider that it is HTML. It did not take long to find the cause, the case turned out to be in the server's response:
Answer Opera

Answer Firefox

It turns out that the server simply “lies” to some browsers. In this case, we can say for sure that he makes a decision only on the basis of the line User-Agent. If, for example, in Opera it is set up in the properties of the Browser identification site as Internet Explorer, or Firefox, the pages start to open wonderfully. The reverse is also true, if you specify a user agent as “Mozilla / 5.0 (Windows; U; Windows NT 5.1; ru-RU)” in Safari, then he will also receive content allegedly application / xhtml + xml, and he will not be able to parse it either:



It turns out that not only Opera suffers, but any other browser that has not been identified as “its own”.

All sites examined with this error are united by one thing - they are written in ASP.NET 2.0. I do not know whether this is a mistake of the Microsoft team, or whether it is the work of home-grown administrators of such sites (even so, not all the sites written in ASP.NET 2.0 suffer from such garbage). I just want to give advice to the developers, which I wrote in the title.

And users can only be advised to change the user agent for such sites. In the same Opera, this can be done on the Network tab in the properties of a broken site.

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


All Articles