📜 ⬆️ ⬇️

Flash + .РФ. What to do?

Actually, the problem.
The flash movie cannot access resources on the server if it is posted on a site with an international name (in particular, the Russian Federation). Seen in Firefox browser under Windows.
Not a very nice glitch, especially given the prevalence of this browser and this platform ... A quick look at the forums did not bring the desired results, and I had to take up the research. So, the details ...

Tests


To begin with - a test flash drive. A code of several lines is enough for our research:

var xml = new XML; xml.onLoad = function() { _root.txt.text = this.toString(); }; xml.load(typeof(_root.link) === "undefined" ? "test.xml" : _root.link); 

And, of course, you need not to forget the text field with the name txt on the first frame. The algorithm is simple: load the “test.xml” file and display its contents. If the “link” parameter is specified, then XML is loaded from the specified address. We will make the corresponding “test.xml” the easiest:

 <?xml version="1.0" encoding="UTF-8"?> <test>Test</test> 

The files “test.swf” and “test.xml” are uploaded to the server and begin the tests. For the tests, two domains were used, one RU and one RF, which are synonymous. Expected result - the flash drive should display the contents of the XML file on any domain. Cope with the test:
Of the common browsers, the test failed only in Firefox (Windows, Linux). The Lynx and W3M browsers did not participate, for obvious reasons.
')

Study


What is wrong? Let's try to test the download of resources from the server via Firebug.

With the domain RU everything is fine:


But with the domain of the Russian Federation something is wrong:


Actually, the problem is visible: the Flash plugin in combination with Firefox makes an address request without encoding the domain name in punycode, which causes the problem.

Okay, try differently. We will do so that the data is loaded from the domain RU. Add to the address of the parameter "link", which we have provided specifically for this case.
It is clear that we will fail because of problems with cross-domain queries. But since we decided to act consistently - we will be consistent.
Q.E.D:


Armed with the documentation , create a file "crossdomain.xml" in the root of the site. This file will be requested from the RU domain (from the domain where the XML file is located), and it should indicate which flash clips can upload data (or, more precisely, on which domains these clips are published).

That's just the question: which domain to allow requests to our XML file? After all, as we have seen, there are certain problems with a Cyrillic domain name ...

We have consistently tested all possible domain names of the Russian Federation:
And ... All without success. All variations on the crossdomain.xml theme of this type did not produce results:
 <?xml version="1.0" encoding="UTF-8"?> <cross-domain-policy> <allow-access-from domain="."/> <allow-access-from domain="*.."/> <allow-access-from domain="xn--80asmaqi.xn--p1ai"/> <allow-access-from domain="*.xn--80asmaqi.xn--p1ai"/> <allow-access-from domain="%D1%81%D0%B0%D0%B9%D1%82%D0%BD%D0%BD.%D1%80%D1%84"/> <allow-access-from domain="*.%D1%81%D0%B0%D0%B9%D1%82%D0%BD%D0%BD.%D1%80%D1%84"/> <allow-access-from domain="%d1%81%d0%b0%d0%b9%d1%82%d0%bd%d0%bd.%d1%80%d1%84"/> <allow-access-from domain="*.%d1%81%d0%b0%d0%b9%d1%82%d0%bd%d0%bd.%d1%80%d1%84"/> </cross-domain-policy> 

It looked like this:


That is, “crossdomain.xml” is loading, but the flash player decides that XML data from this site cannot be downloaded.

Decision


The last option left is to specify "*" as the domain. Thus, "crossdomain.xml" acquired the following form:
 <?xml version="1.0" encoding="UTF-8"?> <cross-domain-policy> <allow-access-from domain="*"/> </cross-domain-policy> 

And - lo and behold!


Morality


The solution to the problem exists. Without bullying . The solution, of course, is not ideal, because access to data through “crossdomain.xml” opens immediately for all sites. However, this is not always a problem, because who needs it - they will be able to access the data in another way, not paying attention to «crossdomain.xml».

Regarding whether to specify the host name in the parameters (flashvars), or whether it needs to be included in the flash movie source, the question remains open. Surely, many developers, in order to protect, prefer to “hardcode” the names of sites in flash drives, and for sure many people prefer to put these addresses into parameters. I fully admit that both are right, depending on the project and tasks. And I prefer not to argue on this topic.

Materials:

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


All Articles