zoukankan      html  css  js  c++  java
  • 过滤关键字

    /// <summary>
            /// 检测是否不带恶意字符
            /// </summary>
            /// <param name="InText"></param>
            /// <returns>如果参数存在不安全字符,则返回true</returns>
            public static bool SqlFilter(string InText)
            {
                string word = "and|exec|insert|select|delete|update|master|or|truncate|declare|.";
                if (InText == null)
                    return false;
                foreach (string i in word.Split('|'))
                {
                    if ((InText.ToLower().IndexOf(i + " ") > -1) || (InText.ToLower().IndexOf(" " + i) > -1))
                    {
                        return true;
                    }
                }
                return false;
            }

            /// <summary>
            /// 编辑框过滤
            /// </summary>
            /// <param name="text"></param>
            /// <returns></returns>
            public static string EditRegText(string text)
            {
                if (!string.IsNullOrEmpty(text))
                {               
                    text = text.Replace("'", "’");               
                }
              
                return text;
            }

            /// <summary>
            /// 过滤部分不安全字符
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public static string RegthisStr(string str)
            {
                return str = str.Replace(".", "").Replace("\"", "“").Replace("'", "‘").Replace("<", "&lt;").Replace(">", "&gt;");
            }

  • 相关阅读:
    python自学笔记
    mybatis审查要点
    session和cookie的简单理解
    linux命令
    [个人原创]关于java中对象排序的一些探讨(三)
    [技术翻译]Guava官方文档Ordering
    [个人原创]关于java中对象排序的一些探讨(二)
    [个人原创]关于java中对象排序的一些探讨(一)
    from 2666
    Euler Project question 34 in python way
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/2001537.html
Copyright © 2011-2022 走看看