Javascript-decoding sequence of browsers (html Decoding, url Decoding, and js decoding)

Source: Internet
Author: User
{Code ...} code above: when the input value is % 26lt % 5cu4e00% 26gt, click test text. The pop-up window content is: & amp; lt; 1 & amp; gt; how does the browser sequentially decode % 26lt % 5cu4e00% 26gt from the input parameters to the pop-up window?

  ');">test

The Code is as follows:inputThe value is:%26lt%5cu4e00%26gtClicktestText, the pop-up content is: <一>
I want to know how the browser%26lt%5cu4e00%26gtWhich of the following operations performs sequential decoding?

Reply content:

  ');">test

The Code is as follows:inputThe value is:%26lt%5cu4e00%26gtClicktestText, the pop-up content is: <一>
I want to know how the browser%26lt%5cu4e00%26gtWhich of the following operations performs sequential decoding?

The server receives the request.

input, IsURLDecode, Changed<\u4e00>
The page data obtained by the browser from the server is changed<\u4e00>
ViewPage source code(Do not right-click the page.Check Element) You can see

test
When the browser is rendering

As the href string of the URLjavascript:alert('<\u4e00>');Decoded by HTMLEntity and changed

');">test

In this step, right-click on the pageTest Link, SelectCheck Element, You can see the actual rendered dom Element

When you click the test link

The execution is actually a javascript code with a string,'<\u4e00>'Which contains an escape character\u4e00ReversalBy the leading character\uIt can be seen that this is a unicode escape, the string of these 6 bytes'\u4e00'Convert to a unicode character that actually occupies 3 bytes'1'The memory occupied by the entire string is

< I >
3c E4 b8 80 3e

If you writeAlert (' <一> '); The internal storage of this string is also like this

When the alert box is finally rendered

The system translates the bytecode into printable encoded characters and renders them on the screen.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.