コード例 #1
0
 public void IsValidAttributeName()
 {
     Assert.False(SecurityElement.IsValidAttributeName("x x"));
     Assert.False(SecurityElement.IsValidAttributeName("x<x"));
     Assert.False(SecurityElement.IsValidAttributeName("x>x"));
     Assert.True(SecurityElement.IsValidAttributeName("x\"x"));
     Assert.True(SecurityElement.IsValidAttributeName("x'x"));
     Assert.True(SecurityElement.IsValidAttributeName("x&x"));
     Assert.False(SecurityElement.IsValidAttributeName(null));
     Assert.True(SecurityElement.IsValidAttributeName(string.Empty));
 }
コード例 #2
0
 public void IsValidAttributeName()
 {
     Assert.IsFalse(SecurityElement.IsValidAttributeName("x x"), "#1");
     Assert.IsFalse(SecurityElement.IsValidAttributeName("x<x"), "#2");
     Assert.IsFalse(SecurityElement.IsValidAttributeName("x>x"), "#3");
     Assert.IsTrue(SecurityElement.IsValidAttributeName("x\"x"), "#4");
     Assert.IsTrue(SecurityElement.IsValidAttributeName("x'x"), "#5");
     Assert.IsTrue(SecurityElement.IsValidAttributeName("x&x"), "#6");
     Assert.IsFalse(SecurityElement.IsValidAttributeName(null), "#7");
     Assert.IsTrue(SecurityElement.IsValidAttributeName(string.Empty), "#8");
 }
コード例 #3
0
        public XmlNodeName(string prefix, string localName)
        {
            if (prefix != null && !SecurityElement.IsValidAttributeName(prefix))
            {
                throw new ArgumentException();
            }
            if (!SecurityElement.IsValidAttributeName(localName))
            {
                throw new ArgumentException();
            }

            _prefix    = prefix;
            _localName = localName;
        }
コード例 #4
0
        public XmlName(string nsName, string localName)
        {
            if (nsName == null)
            {
                throw new ArgumentException();
            }
            if (!SecurityElement.IsValidAttributeName(localName))
            {
                throw new ArgumentException();
            }

            _namespace = nsName;
            _localName = localName;
        }
コード例 #5
0
 // Add an attribute to the specified security element.
 private static SecurityElement AddAttribute(
     SecurityElement xmlElement,
     string attributeName,
     string attributeValue)
 {
     if (xmlElement != null)
     {
         // Verify that the attribute name and value are valid XML formats.
         if (SecurityElement.IsValidAttributeName(attributeName) &&
             SecurityElement.IsValidAttributeValue(attributeValue))
         {
             // Add the attribute to the security element.
             xmlElement.AddAttribute(attributeName, attributeValue);
         }
     }
     return(xmlElement);
 }
コード例 #6
0
ファイル: TestSecurityElement.cs プロジェクト: ForNeVeR/pnet
    // Test the valid string testing operators.
    public void TestSecurityElementValidStrings()
    {
        Assert("ValidAttrName (1)",
               !SecurityElement.IsValidAttributeName(null));
        Assert("ValidAttrName (2)",
               !SecurityElement.IsValidAttributeName(""));
        Assert("ValidAttrName (3)",
               !SecurityElement.IsValidAttributeName("a<b"));
        Assert("ValidAttrName (4)",
               !SecurityElement.IsValidAttributeName("a>b"));
        Assert("ValidAttrName (5)",
               !SecurityElement.IsValidAttributeName("&amp;"));
        Assert("ValidAttrName (6)",
               !SecurityElement.IsValidAttributeName(" "));
        Assert("ValidAttrName (7)",
               SecurityElement.IsValidAttributeName("fooBar"));
        Assert("ValidAttrName (8)",
               SecurityElement.IsValidAttributeName("123"));

        Assert("ValidAttrValue (1)",
               !SecurityElement.IsValidAttributeValue(null));
        Assert("ValidAttrValue (2)",
               SecurityElement.IsValidAttributeValue(""));
        Assert("ValidAttrValue (3)",
               !SecurityElement.IsValidAttributeValue("a<b"));
        Assert("ValidAttrValue (4)",
               !SecurityElement.IsValidAttributeValue("a>b"));
        Assert("ValidAttrValue (5)",
               SecurityElement.IsValidAttributeValue("&amp;"));
        Assert("ValidAttrValue (6)",
               SecurityElement.IsValidAttributeValue(" "));
        Assert("ValidAttrValue (7)",
               SecurityElement.IsValidAttributeValue("fooBar"));
        Assert("ValidAttrValue (8)",
               SecurityElement.IsValidAttributeValue("123"));
        Assert("ValidAttrValue (9)",
               !SecurityElement.IsValidAttributeValue("\""));

        Assert("ValidTag (1)",
               !SecurityElement.IsValidTag(null));
        Assert("ValidTag (2)",
               !SecurityElement.IsValidTag(""));
        Assert("ValidTag (3)",
               !SecurityElement.IsValidTag("a<b"));
        Assert("ValidTag (4)",
               !SecurityElement.IsValidTag("a>b"));
        Assert("ValidTag (5)",
               !SecurityElement.IsValidTag("&amp;"));
        Assert("ValidTag (6)",
               !SecurityElement.IsValidTag(" "));
        Assert("ValidTag (7)",
               SecurityElement.IsValidTag("fooBar"));
        Assert("ValidTag (8)",
               SecurityElement.IsValidTag("123"));

        Assert("ValidText (1)",
               !SecurityElement.IsValidText(null));
        Assert("ValidText (2)",
               SecurityElement.IsValidText(""));
        Assert("ValidText (3)",
               !SecurityElement.IsValidText("a<b"));
        Assert("ValidText (4)",
               !SecurityElement.IsValidText("a>b"));
        Assert("ValidText (5)",
               SecurityElement.IsValidText("&amp;"));
        Assert("ValidText (6)",
               SecurityElement.IsValidText(" "));
        Assert("ValidText (7)",
               SecurityElement.IsValidText("fooBar"));
        Assert("ValidText (8)",
               SecurityElement.IsValidText("123"));
        Assert("ValidText (9)",
               SecurityElement.IsValidText("\""));
    }