zoukankan      html  css  js  c++  java
  • 检测并替换用户输入的恶意字符

     /// <summary>
            /// 该方法检测并替换用户输入的恶意字符
            /// </summary>
            /// <param name="text">用户输入的文字 </param>        
            /// <returns>返回验证后的文字 </returns>
            public static string InputText(string text)
            {
                text = text.ToLower().Trim();
                if (string.IsNullOrEmpty(text))
                {
                    return string.Empty;
                }
                else
                {
                    text = Regex.Replace(text, ".", "。");
                    //text = Regex.Replace(text, "=", "");
                    //text = Regex.Replace(text, "%", "");
                    text = Regex.Replace(text, "'", "’");
                    //text = Regex.Replace(text, "select", "");
                    //text = Regex.Replace(text, "insert", "");
                    //text = Regex.Replace(text, "delete", "");
                    //text = Regex.Replace(text, "or", "");              
                    //text = Regex.Replace(text, "--", "");
                    //text = Regex.Replace(text, "and", "");
                    //text = Regex.Replace(text, "where", "");
                    //text = Regex.Replace(text, "update", "");              
                    //text = Regex.Replace(text, "master", "");
                    //text = Regex.Replace(text, "exec", "");
                    //text = Regex.Replace(text, " <", "");
                    //text = Regex.Replace(text, ">", "");
                }
                return text;
            }
  • 相关阅读:
    MP3 Lame 转换 参数 设置(转)
    数据库SQL优化大总结之 百万级数据库优化方案(转)
    IndexedDB:浏览器里内置的数据库(转)
    【译】微型ORM:PetaPoco【不完整的翻译】(转)
    'NoneType' object has no attribute '__getitem__'
    关于python的整形(int)自动转长整形(long)的问题
    1-redis使用笔记
    Flask deployment on gunicorn with flask script
    Celery从入门到放弃
    SELECT中的CAST
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/2001540.html
Copyright © 2011-2022 走看看