Note: The regular expression of JavaScript and the regular expressions of .NET have some differences. -zz

xiaoxiao2021-03-06  115

These two days, the 9CBS has someone registered Chinese ID. 9CBS is not allowed to register Chinese IDs, for this purpose, in the registration page specifically with ASP: RegularExpressionValidator, the server is specifically used by IsValID. Judging.

By contacting netizens, netizen feedback is: is to implement the registration Chinese name by disabling all JS to disable all JS. But we are the server with check. I have been investigated, I found that the regular expression is wrong. Writtered into validationExpression = "/ w "

Disable all JS as follows.

Query the help of MSDN, with / W has the following description:

Match with any word character. Equivalently Unicode Character Class [/ P {LL} / P {lu} / p {lt} / p {lo} / p {nd} / p {pc}]. If you specify a behavior that meets ECMAScript with an ECMAScript option, / W is equivalent to [A-ZA-Z_0-9].

Dizzy, I haven't said that the book I have seen before. Inspected some books about regular expressions, fainting, many when they explain to / W, write is the matching of any word characters, including AZ, AZ, 0-9, and low sliding lines _, without mentioning unicode this part. Frank, was made.

And the above saying is JS, when learning this part, just pay attention to reading book content, did not pay attention to MSDN, such a big loophole.

The regular expression is modified to: ^ [A-ZA-Z0-9 _] $ fixes this problem.

Placing it is disabled from JS, you can register Chinese, as follows:

If you use / w to check:

If the client does not disable JS, the verification of the layer of JS is actually the check is [A-ZA-Z_0-9], if the user disables JS, on the server, it is actually verified [/ P {ll} / p {lu} / p {lt} / p {lo} / p {nd} / p {pc}] The username in the server side also verified.

The Chinese ID registered in 9CBS, according to the 9CBS system, all the benefits of non-normal pathways, 9CBS vulnerabilities, 9CBS are not protected. In addition to a few accounts that help 9cbs solve the problem, others will be deleted.

转载请注明原文地址:https://www.9cbs.com/read-125473.html

New Post(0)