Completely solves the "Request. Form values detected from the client" and detects potential risks from the client.

Source: Internet
Author: User

Completely solves the "Request. Form values detected from the client" and detects potential risks from the client.

It is not recommended to set validateRequest = "false" because the application needs to explicitly check all input, which is inconvenient.

1. The front end uses escape to encode the string, for example:

var editor = $("textarea[name='editorValue']");$("#contents").val(escape(editor.val()));var formData = new FormData($("#frm")[0]);

2. the backend uses the Server. UrlDecode Method for decoding, for example:

model.contents = Server.UrlDecode(model.contents);

3. The View page is displayed in the editor, for example:

ue.addListener('ready', function (editor) {    var contents = decodeHtml("@content.contents");    ue.setContent(contents);});
JS method decodeHtml code:
function decodeHtml(val) {    return val.replace(/&lt;/g, "<")              .replace(/&gt;/g, ">")              .replace(/&quot;/g, "\"")              .replace(/&#039;/g, "'")              .replace(/&amp;/g, "&");}function encodeHtml(val) {    return val.replace(/&/g, "&amp;")              .replace(/</g, "&lt;")              .replace(/>/g, "&gt;")              .replace(/"/g, "&quot;")              .replace(/'/g, "&#039;");}

 

Related Article

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.