close

預止XSS攻擊的函式....
protected string GetSafeHtml(object o)
    {
        if (o != null)
        {
            string o2 = (string)o;
            if (o2.IndexOf("<script",StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                while (true)
                {
                    int index = o2.IndexOf("<script",
                              StringComparison.InvariantCultureIgnoreCase);
                    if (index == -1) break;
                    o2 = o2.Replace(o2.Substring(index, 8), "<!-- ");
                    index = o2.IndexOf("</script>",
                        StringComparison.InvariantCultureIgnoreCase);
                    o2 = o2.Replace(o2.Substring(index, 9), " !-->");
                }
            }
            return o2;
        }
        return string.Empty;
    }}
   
    private bool DetectInjection(string input)
    {
        if (input.IndexOf("'") != -1 ||
           input.IndexOf("--") != -1 ||
           input.IndexOf(" OR ") != -1)
            return true;
        return false;
    } 

網頁設計 網路行銷 網路廣告

arrow
arrow
    全站熱搜

    itouch網站銀行 發表在 痞客邦 留言(0) 人氣()