• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Sanitizer.DefaultHtmlSanitizer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AjaxControlToolkit.HtmlEditor.Sanitizer.DefaultHtmlSanitizer的典型用法代码示例。如果您正苦于以下问题:C# DefaultHtmlSanitizer类的具体用法?C# DefaultHtmlSanitizer怎么用?C# DefaultHtmlSanitizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultHtmlSanitizer类属于AjaxControlToolkit.HtmlEditor.Sanitizer命名空间,在下文中一共展示了DefaultHtmlSanitizer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MakeSureItSanitized

        public void MakeSureItSanitized(string htmlFragment, string message)
        {
            var target = new DefaultHtmlSanitizer();
            var elementWhiteList = CreateElementWhiteList();

            var actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            if(htmlFragment != "See Below")
                StringAssert.AreNotEqualIgnoringCase(htmlFragment, actual, message);
        }
开发者ID:CharlieBP,项目名称:AjaxControlToolkit,代码行数:10,代码来源:HaCkerOrgXMLTest.cs


示例2: AnchorTagContentReplaceXSSTest

        public void AnchorTagContentReplaceXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"http://www.gohttp://www.google.com/ogle.com/\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<A HREF=\"http&#x3A;&#x2F;&#x2F;www&#x2E;gohttp&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com&#x2F;ogle&#x2E;com&#x2F;\">XSS</A>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:CharlieBP,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例3: AnchorTagDownlevelHiddenBlockXSSTest

        public void AnchorTagDownlevelHiddenBlockXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"http://www.codeplex.com?url=<!--[if gte IE 4]><SCRIPT>alert('XSS');</SCRIPT><![endif]-->\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<a href=\"http://www.codeplex.com?url=&lt;!--[if gte IE 4]&gt;&lt;&gt;alert(&#39;XSS&#39;);&lt;/&gt;&lt;![endif]--&gt;\">XSS</a>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例4: AnchorTagDownlevelHiddenBlockXSSTest

        public void AnchorTagDownlevelHiddenBlockXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"http://www.codeplex.com?url=<!--[if gte IE 4]><SCRIPT>alert('XSS');</SCRIPT><![endif]-->\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<A HREF=\"http&#x3A;&#x2F;&#x2F;www&#x2E;codeplex&#x2E;com&#x3F;url&#x3D;&#x26;lt&#x3B;&#x21;&#x2D;&#x2D;&#x5B;if&#x20;gte&#x20;IE&#x20;4&#x5D;&#x26;gt&#x3B;&#x26;lt&#x3B;&#x26;gt&#x3B;alert&#x28;&#x26;&#x23;39&#x3B;XSS&#x26;&#x23;39&#x3B;&#x29;&#x3B;&#x26;lt&#x3B;&#x2F;&#x26;gt&#x3B;&#x26;lt&#x3B;&#x21;&#x5B;endif&#x5D;&#x2D;&#x2D;&#x26;gt&#x3B;\">XSS</A>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:CharlieBP,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例5: AnchorTagDwordEncodingXSSTest

        public void AnchorTagDwordEncodingXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"http://1113982867/\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<a href=\"http://1113982867/\">XSS</a>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例6: DivExpressionXSSTest

        public void DivExpressionXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<DIV STYLE=\"width: expression(alert('XSS'));\">";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<div style=\"width:(alert(&#39;XSS&#39;));\"></div>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例7: DivBackgroundImageXSSTest

        public void DivBackgroundImageXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<div style=\"background-image: url(\"></div>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例8: DivStyleExpressionHtmlQuotesEncapsulation1XSSTest

        public void DivStyleExpressionHtmlQuotesEncapsulation1XSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<Div style=\"background-color: expression(<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>)\">";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<div style=\"background-color:(&lt;a=\">\" SRC=\"http://ha.ckers.org/xss.js\">)\"></div>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例9: XmlWithEmbeddedScriptXSSTest

        public void XmlWithEmbeddedScriptXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<XML SRC=\"xsstest.xml\" ID=I></XML><SPAN DATASRC=#I DATAFLD=C DATAFORMATAS=HTML></SPAN>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<SPAN></SPAN>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例10: AnchorTagJavascriptLinkLocationXSSTest

        public void AnchorTagJavascriptLinkLocationXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"javascript:document.location='http://www.google.com/'\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<A HREF=\"\">XSS</A>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例11: DivStyleExpressionDownlevelHiddenBlockXSSTest

        public void DivStyleExpressionDownlevelHiddenBlockXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<Div style=\"background-color: expression(<!--[if gte IE 4]><SCRIPT>alert('XSS');</SCRIPT><![endif]-->)\">";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<div style=\"background-color:(&lt;!--[if gte IE 4]&gt;&lt;&gt;alert(&#39;XSS&#39;);&lt;/&gt;&lt;![endif]--&gt;)\"></div>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例12: AnchorTagStyleExpressionXSSTest

        public void AnchorTagStyleExpressionXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "exp/*<A STYLE='no\\xss:noxss(\"*//*\");xss:&#101;x&#x2F;*XSS*//*/*/pression(alert(\"XSS\"))'>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "exp/*<a></a>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例13: AnchorTagExtraneousOpenBracketsXSSTest

        public void AnchorTagExtraneousOpenBracketsXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"http://www.codeplex.com?url=<<SCRIPT>alert(\"XSS\");//<</SCRIPT>\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<a href=\"http://www.codeplex.com?url=&lt;&lt;&gt;alert(\"></a>\">XSS";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例14: AnchorTagProtocolResolutionScriptXSSTest

        public void AnchorTagProtocolResolutionScriptXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"http://www.codeplex.com?url=<SCRIPT SRC=//ha.ckers.org/.j>\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<a href=\"http://www.codeplex.com?url=&lt;SRC=//ha.ckers.org/.j&gt;\">XSS</a>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例15: AnchorTagProtocolResolutionXSSTest

        public void AnchorTagProtocolResolutionXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"//www.google.com/\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<a href=\"//www.google.com/\">XSS</a>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例16: AnchorTagNoQuotesXSSTest

        public void AnchorTagNoQuotesXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"http://www.codeplex.com?url=<SCRIPT>a=/XSS/alert(a.source)</SCRIPT>\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<a href=\"http://www.codeplex.com?url=&lt;&gt;a=/XSS/alert(a.source)&lt;/&gt;\">XSS</a>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例17: AnchorTagNonAlphaNonDigitXSSTest

        public void AnchorTagNonAlphaNonDigitXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<A HREF=\"http://www.codeplex.com?url=<SCRIPT/XSS SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>\">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<a href=\"http://www.codeplex.com?url=&lt;/XSS SRC=\">\">XSS</a>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例18: AnchorTagMixedEncodingXSSTest

        public void AnchorTagMixedEncodingXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = @"<A HREF=""h
            tt	p://6&#9;6.000146.0x7.147/"">XSS</A>";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<a href=\"h\r\ntt\tp://6&amp;#9;6.000146.0x7.147/\">XSS</a>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:15,代码来源:DefaultHtmlSanitizerTests.cs


示例19: DivHtmlQuotesEncapsulation7XSSTest

        public void DivHtmlQuotesEncapsulation7XSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<Div style=\"background-color: http://www.codeplex.com?url=<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>\">";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<div style=\"background-color: http://www.codeplex.com?url=&lt;&gt;document.write(\"></div>PT SRC=\"http://ha.ckers.org/xss.js\">\">";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs


示例20: DivNoQuotesXSSTest

        public void DivNoQuotesXSSTest()
        {
            // Arrange
            DefaultHtmlSanitizer target = new DefaultHtmlSanitizer();
            Dictionary<string, string[]> elementWhiteList = CreateElementWhiteList();

            // Act
            string htmlFragment = "<Div style=\"background-color: http://www.codeplex.com?url=<SCRIPT>a=/XSS/alert(a.source)</SCRIPT>\">";
            string actual = target.GetSafeHtmlFragment(htmlFragment, elementWhiteList);

            // Assert
            string expected = "<div style=\"background-color: http://www.codeplex.com?url=&lt;&gt;a=/XSS/alert(a.source)&lt;/&gt;\"></div>";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
开发者ID:DevExpress,项目名称:AjaxControlToolkit,代码行数:14,代码来源:DefaultHtmlSanitizerTests.cs



注:本文中的AjaxControlToolkit.HtmlEditor.Sanitizer.DefaultHtmlSanitizer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Actor.ActorRef类代码示例发布时间:2022-05-24
下一篇:
C# Ajancy.Kimia_Ajancy类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap