Add invisible client comments to javascript programs

Source: Internet
Author: User
On the ASP. NET page, when we write JavaScript scripts and add comments, these comments are often sent to the client together with the Javascript script. Visitors only need to view HTML source files in the browser to see these comments.

Of course, we can choose not to use annotations. However, some JavascriptCodeIt must be annotated. For example, some code is intentionally written in disorder to confuse malicious attackers. If there is no comment, I am afraid I am confused, but I have added a comment, so I will not give the attacker a roadmap.

Is there a way to make JavaScript comments invisible on the client?

The answer is simple: javascript comments + server comments!

Line comment:

// <% -- Write a line comment here-- %>

Block annotation Syntax:

/* <% --
Write the comment statement block here,
Multiple rows.
-- %> */

Our own developers can read the complete annotations, And the compiled ASP.. NET page will ignore the comments in <% -- to -- %>. Malicious attackers will not see these comments on the client.

He can only see: // or/**/and then immediately fainted!

You may have known this trick, but I thought of it myself. Cainiao are not always vegetarian, but occasionally sick bugs.
Original article: http://www.cnblogs.com/leadzen/archive/2008/04/22/1163894.html

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.