zoukankan      html  css  js  c++  java
  • SQL过滤敏感字符

    /// <summary>
            /// SQL过滤敏感字符
            /// </summary>
            /// <param name="InText">要特殊过滤的字符串</param>
            /// <returns>过滤后的字符串</returns>
            public static string SqlFilterSpecial(string InText)
            {
                if (InText == "") //如果字符串为空,直接返回。
                {
                    return InText;
                }
                else
                {
                    InText = InText.Replace("and ", "");
                    InText = InText.Replace("exec ", "");
                    InText = InText.Replace("insert ", "");
                    InText = InText.Replace("select ", "");
                    InText = InText.Replace("delete ", "");
                    InText = InText.Replace("update ", "");
                    InText = InText.Replace(" and", "");
                    InText = InText.Replace(" exec", "");
                    InText = InText.Replace(" insert", "");
                    InText = InText.Replace(" select", "");
                    InText = InText.Replace(" delete", "");
                    InText = InText.Replace(" update ", "");
                    InText = InText.Replace("chr ", "");
                    InText = InText.Replace("mid ", "");
                    InText = InText.Replace(" chr", "");
                    InText = InText.Replace(" mid", "");
                    InText = InText.Replace("master ", "");
                    InText = InText.Replace(" master", "");
                    InText = InText.Replace("or ", "");
                    InText = InText.Replace(" or", "");
                    InText = InText.Replace("truncate ", "");
                    InText = InText.Replace("char ", "");
                    InText = InText.Replace("declare ", "");
                    InText = InText.Replace("join ", "");
                    InText = InText.Replace("union ", "");
                    InText = InText.Replace("truncate ", "");
                    InText = InText.Replace(" char", "");
                    InText = InText.Replace(" declare", "");
                    InText = InText.Replace(" join", "");
                    InText = InText.Replace(" union", "");
                    InText = InText.Replace("'", "");
                    InText = InText.Replace("<", "");
                    InText = InText.Replace(">", "");
                    InText = InText.Replace("%", "");
                    InText = InText.Replace("'delete", "");
                    InText = InText.Replace("''", "");
                    InText = InText.Replace("\"\"", "");
                    InText = InText.Replace(",", "");
                    InText = InText.Replace(">=", "");
                    InText = InText.Replace("=<", "");
                    InText = InText.Replace("--", "");
                    InText = InText.Replace("_", "");
                    InText = InText.Replace(";", "");
                    InText = InText.Replace("||", "");
                    InText = InText.Replace("[", "");
                    InText = InText.Replace("]", "");
                    InText = InText.Replace("&", "");
                    InText = InText.Replace("/", "");
                    InText = InText.Replace("?", "");
                    InText = InText.Replace(">?", "");
                    InText = InText.Replace("?<", "");
                    InText = InText.Replace(" ", "");
                    return InText;
                }
            }
  • 相关阅读:
    杨老师课堂_VBA学习教程之根据部门列创建工作表
    杨老师课堂_Java核心技术下之控制台模拟微博用户注册案例
    杨老师课堂_Java核心技术下之控制台模拟记事本案例
    杨校老师课堂之JavaScript右下角广告弹框教程
    JavaScript的数组知识案例之随机点名器
    SET QUOTED_IDENTIFIER ON
    SET ANSI_NULLS ON
    OLEDB和ODBC的区别
    教你认识主板上的主要芯片
    递归和迭代有什么区别
  • 原文地址:https://www.cnblogs.com/MySpace/p/1599871.html
Copyright © 2011-2022 走看看