diff options
author | Atsushi Eno <atsushieno@veritas-vos-liberabit.com> | 2013-08-06 09:38:14 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@veritas-vos-liberabit.com> | 2013-08-06 09:38:14 +0400 |
commit | 439046726f251319c937d8b8cda33b5df4616cfc (patch) | |
tree | dd0a9ddff80708de9c18d0000293b85bb86b4a92 /mcs/class/System.XML | |
parent | 70d411b525b7e4b218db5e20a5357542c63c819b (diff) |
implement character validation methods in XmlConvert. Fix bug #11910.
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlConvert.cs | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/mcs/class/System.XML/System.Xml/XmlConvert.cs b/mcs/class/System.XML/System.Xml/XmlConvert.cs index c00965d425a..8497c85eee9 100644 --- a/mcs/class/System.XML/System.Xml/XmlConvert.cs +++ b/mcs/class/System.XML/System.Xml/XmlConvert.cs @@ -928,47 +928,60 @@ namespace System.Xml { #if NET_4_0 public static bool IsNCNameChar (char ch) { - throw new NotImplementedException (); + return XmlChar.IsNCNameChar (ch); } public static bool IsPublicIdChar (char ch) { - throw new NotImplementedException (); + return XmlChar.IsPubidChar (ch); } public static bool IsStartNCNameChar (char ch) { - throw new NotImplementedException (); + return XmlChar.IsFirstNameChar (ch); } public static bool IsWhitespaceChar (char ch) { - throw new NotImplementedException (); + return XmlChar.IsWhitespace (ch); } public static bool IsXmlChar (char ch) { - throw new NotImplementedException (); + return XmlChar.IsValid (ch); } public static bool IsXmlSurrogatePair (char lowChar, char highChar) { - throw new NotImplementedException (); + return 0xD800 <= lowChar && lowChar <= 0xDBFF && 0xDC00 <= highChar && highChar <= 0xDFFF; } public static string VerifyPublicId (string publicId) { - throw new NotImplementedException (); + if (publicId == null) + throw new ArgumentNullException ("publicId"); + if (XmlChar.IsPubid (publicId)) + return publicId; + throw new XmlException (string.Format ("'{0}' is not a valid PUBLIC ID", publicId)); } public static string VerifyWhitespace (string content) { - throw new NotImplementedException (); + if (content == null) + throw new ArgumentNullException ("content"); + if (XmlChar.IsWhitespace (content)) + return content; + throw new XmlException (string.Format ("'{0}' is not whitespace", content)); } public static string VerifyXmlChars (string content) { - throw new NotImplementedException (); + if (content == null) + throw new ArgumentNullException ("content"); + var idx = XmlChar.IndexOfInvalid (content, true); + if (idx < 0) + return content; + throw new XmlException (string.Format ("Invalid XML character was found in the content, at index {0}.", idx)); } #endif } |