Parameter verification prevents SQL injection attacks 1

Source: Internet
Author: User
 FlockRecommendation
 /// <Summary>          /// Parameter verification prevents SQL injection attacks 1          /// Call: object [] ARGs = new object [6] {realname, address, areacode, contacttel, email, proviceid };          /// If (! Basecheck. checkparams (ARGs ))          ///{          /// Common. showdsmsg ("the content you entered cannot pass ");          /// Return;          ///}          /// </Summary>          /// <Param name = "ARGs"> </param>          /// <Returns> </returns>          Public   Static  Bool Checkparams ( Params   Object [] ARGs ){ String [] Lawlesses = { "=" , "'" }; If (Lawlesses = Null | Lawlesses. Length <= 0) Return   True ; // Construct a regular expression,              // For example, the regular expression is. * [= | ']. * (because it is intended to be a common and easy-to-Modify function, there is an additional step from the character array to the regular expression. In actual use, you can directly write the regular expression;              String Str_regex = ".*[" ;For ( Int I = 0; I <lawlesses. Length-1; I ++) str_regex + = lawlesses [I] + "|" ; Str_regex + = lawlesses [lawlesses. Length-1] + "]. *" ; Foreach ( Object ARG In ARGs ){ If (ARG Is   String ) // If it is a string, directly check { If (RegEx. Matches (Arg. tostring (), str_regex). Count> 0)Return   False ;} Else   If (ARG Is Icollection) // If it is a set, check whether the element in the set is a string. { Foreach ( Object OBJ In (Icollection) Arg ){ If (OBJ Is   String ){ If (RegEx. Matches (obj. tostring (), str_regex). Count> 0) Return   False ;}}}} Return   True ;}

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.