Reputation: 53
In one site there is this code:
document.write(unescape('%41%54%50%20%2f%20%20%57%54%41%20%4d%6f%73%63%6f%77'));
And this generate
ATP / WTA Moscow (Shvedova - Pavlyuchenkova)
But if run that code I only get ATP / WTA Moscow
Any ideas why this is happening ?
Edit:// Here is the site
check this match
ATP / WTA Moscow (Makarova - Cibulkova)
Upvotes: 0
Views: 1360
Reputation: 944175
There are 18 encoded characters in the string you provide.
ATP / WTA Moscow
is 18 characters long.
Whatever generates (Shvedova - Pavlyuchenkova)
, it isn't the code you provided.
That said, unescape
is broken for non-ASCII characters and so is deprecated
Here is the site…
The text in brackets appears after the script element as regular HTML.
Upvotes: 1
Reputation: 207537
It is impossible for that string to produce that other line. Each %XX represents a single letter. The unescape can not magically make up characters that are not in that string.
With the edit. View the page source you will see that the text in the () is not in the unescape call
<script language='Javascript'>document.write(unescape('%41%54%50%20%2f%20%20%57%54%41%20%4d%6f%73%63%6f%77'));</script> (Kuznetsov - Berlocq)</a></td>
Upvotes: 0
Reputation: 66364
str = Array.prototype.map.call('ATP / WTA Moscow (Shvedova - Pavlyuchenkova)', function(x){return '%'+x.charCodeAt(0).toString(16);}).join('');
str === '%41%54%50%20%2f%20%20%57%54%41%20%4d%6f%73%63%6f%77%20%28%53%68%76%65%64%6f%76%61%20%2d%20%50%61%76%6c%79%75%63%68%65%6e%6b%6f%76%61%29';
str !== '%41%54%50%20%2f%20%20%57%54%41%20%4d%6f%73%63%6f%77';
Upvotes: 0
Reputation: 21106
(Shvedova - Pavlyuchenkova)
is being added after that code.
%41%54%50%20%2f%20%20%57%54%41%20%4d%6f%73%63%6f%77
only represents "ATP / WTA Moscow"
Each 3 characters in the escaped string represents 1 readable character.
% = escape and [0-9a-f] = hex representation of a character
%20 = character 32 = " " [space]
%41 = character 65 = "A"
Upvotes: 0