diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2004-12-26 19:26:30 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2004-12-26 19:26:30 +0300 |
commit | ea5f087e847bf843a5b0420dc8e068f07707e84c (patch) | |
tree | 3ed429c513f0b56a4c5199baa2c5efffc414b6cb /mcs/class | |
parent | 09b5317ffd7e190e3d80c9df0b5f3642a7f2c8cd (diff) |
2004-12-26 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchema.cs : XmlResolver.ResolveUri() may return null.
* XmlParserContext.cs : all the string properties must not be set as
null. Thanks to Joshua.
* XmlTextReader.cs,
DTDObjectModel.cs,
DTDReader.cs : XmlResolver.ResolveUri() may return null.
* XsdValidatingReader.cs : XmlResolver.ResolveUri() may return null.
* XslFunction.cs,
Compiler.cs : XmlResolver.ResolveUri() may return null.
svn path=/trunk/mcs/; revision=38084
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Schema/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs | 4 | ||||
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs | 3 | ||||
-rwxr-xr-x | mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs | 7 | ||||
-rwxr-xr-x | mcs/class/System.XML/System.Xml.Schema/ChangeLog | 4 | ||||
-rwxr-xr-x | mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs | 3 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 8 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/DTDObjectModel.cs | 2 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/DTDReader.cs | 2 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlParserContext.cs | 36 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextReader.cs | 58 |
12 files changed, 86 insertions, 50 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog b/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog index c265b8f4e82..368b6b64d56 100644 --- a/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog @@ -1,3 +1,7 @@ +2004-12-22 Atsushi Enomoto <atsushi@ximian.com> + + * XsdValidatingReader.cs : XmlResolver.ResolveUri() may return null. + 2004-12-16 Atsushi Enomoto <atsushi@ximian.com> * XsdValidatingReader.cs : added ActualSchemaType to context type. diff --git a/mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs b/mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs index 4c5a4c66732..51cbbcb98c0 100644 --- a/mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs +++ b/mcs/class/System.XML/Mono.Xml.Schema/XsdValidatingReader.cs @@ -215,6 +215,7 @@ namespace Mono.Xml.Schema // It is used only for independent XmlReader use, not for XmlValidatingReader. #if NET_2_0 + [Obsolete] public override object ReadTypedValue () #else public object ReadTypedValue () @@ -1507,9 +1508,10 @@ namespace Mono.Xml.Schema private XmlSchema ReadExternalSchema (string uri) { Uri absUri = resolver.ResolveUri ((BaseURI != "" ? new Uri (BaseURI) : null), uri); + string absUriString = absUri != null ? absUri.ToString () : String.Empty; XmlTextReader xtr = null; try { - xtr = new XmlTextReader (absUri.ToString (), + xtr = new XmlTextReader (absUriString, (Stream) resolver.GetEntity ( absUri, null, typeof (Stream)), NameTable); diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog index c94debf9256..6ec06b0f79b 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog @@ -1,3 +1,8 @@ +2004-12-22 Atsushi Enomoto <atsushi@ximian.com> + + * XslFunction.cs, + Compiler.cs : XmlResolver.ResolveUri() may return null. + 2004-12-01 Atsushi Enomoto <atsushi@ximian.com> * Compiler.cs : XPathNavigatorNsm needed more love. Clone() does not diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs b/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs index fcde5be0d3b..8cea656e48a 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs @@ -195,10 +195,11 @@ namespace Mono.Xml.Xsl // todo: detect recursion Uri baseUriObj = (Input.BaseURI == String.Empty) ? null : new Uri (Input.BaseURI); Uri absUri = res.ResolveUri (baseUriObj, url); + string absUriString = absUri != null ? absUri.ToString () : String.Empty; using (Stream s = (Stream)res.GetEntity (absUri, null, typeof(Stream))) { - XmlValidatingReader vr = new XmlValidatingReader (new XmlTextReader (absUri.ToString (), s, nsMgr.NameTable)); + XmlValidatingReader vr = new XmlValidatingReader (new XmlTextReader (absUriString, s, nsMgr.NameTable)); vr.ValidationType = ValidationType.None; XPathNavigator n = new XPathDocument (vr, XmlSpace.Preserve).CreateNavigator (); vr.Close (); diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs index 102b9ac5f3c..8bb6c89d332 100755 --- a/mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslFunctions.cs @@ -237,7 +237,8 @@ namespace Mono.Xml.Xsl // Debug.WriteLine ("THIS: " + thisUri); // Debug.WriteLine ("BASE: " + baseUri); XmlResolver r = p.Resolver; - + if (r == null) + return null; Uri uriBase = null; if (! object.ReferenceEquals (baseUri, VoidBaseUriFlag) && baseUri != String.Empty) uriBase = r.ResolveUri (null, baseUri); @@ -254,7 +255,7 @@ namespace Mono.Xml.Xsl Uri uri = Resolve (itr.Current.Value, baseUri != null ? baseUri : /*itr.Current.BaseURI*/doc.BaseURI, xsltContext.Processor); if (!got.ContainsKey (uri)) { got.Add (uri, null); - if (uri.ToString () == "") { + if (uri != null && uri.ToString () == "") { XPathNavigator n = doc.Clone (); n.MoveToRoot (); list.Add (n); @@ -270,7 +271,7 @@ namespace Mono.Xml.Xsl { Uri uri = Resolve (arg0, baseUri != null ? baseUri : doc.BaseURI, xsltContext.Processor); XPathNavigator n; - if (uri.ToString () == "") { + if (uri != null && uri.ToString () == "") { n = doc.Clone (); n.MoveToRoot (); } else diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog index 31656f51a0b..c238d118202 100755 --- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog @@ -1,3 +1,7 @@ +2004-12-22 Atsushi Enomoto <atsushi@ximian.com> + + * XmlSchema.cs : XmlResolver.ResolveUri() may return null. + 2004-12-16 Atsushi Enomoto <atsushi@ximian.com> * XmlSchemaValidator.cs : ValidateElement() was not LAMESPEC. Added diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs index e123f6ebfe0..f286f0eacca 100755 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs @@ -578,7 +578,8 @@ namespace System.Xml.Schema Uri baseUri = null; if (this.SourceUri != null && this.SourceUri != String.Empty) baseUri = new Uri (this.SourceUri); - return resolver.ResolveUri (baseUri, relativeUri).ToString (); + Uri abs = resolver.ResolveUri (baseUri, relativeUri); + return abs != null ? abs.ToString () : String.Empty; } internal bool IsNamespaceAbsent (string ns) diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index 0408b09c2b7..8ff8439e972 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,11 @@ +2004-12-22 Atsushi Enomoto <atsushi@ximian.com> + + * XmlParserContext.cs : all the string properties must not be set as + null. Thanks to Joshua. + * XmlTextReader.cs, + DTDObjectModel.cs, + DTDReader.cs : XmlResolver.ResolveUri() may return null. + 2004-12-17 Atsushi Enomoto <atsushi@ximian.com> * XmlReaderBinarySupport.cs : added support class for base64/binhex diff --git a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs index 0d53533d5e0..35f1dc0b71b 100644 --- a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs +++ b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs @@ -1010,7 +1010,7 @@ namespace Mono.Xml } Uri absUri = resolver.ResolveUri (baseUri, SystemId); - string absPath = absUri.ToString (); + string absPath = absUri != null ? absUri.ToString () : String.Empty; if (Root.ExternalResources.ContainsKey (absPath)) LiteralEntityValue = (string) Root.ExternalResources [absPath]; Stream s = null; diff --git a/mcs/class/System.XML/System.Xml/DTDReader.cs b/mcs/class/System.XML/System.Xml/DTDReader.cs index 8c76d787102..fea93bb1d6d 100644 --- a/mcs/class/System.XML/System.Xml/DTDReader.cs +++ b/mcs/class/System.XML/System.Xml/DTDReader.cs @@ -1604,7 +1604,7 @@ namespace System.Xml } Uri absUri = DTD.Resolver.ResolveUri (baseUri, url); - string absPath = absUri.ToString (); + string absPath = absUri != null ? absUri.ToString () : String.Empty; foreach (XmlParserInput i in parserInputStack.ToArray ()) { if (i.BaseURI == absPath) diff --git a/mcs/class/System.XML/System.Xml/XmlParserContext.cs b/mcs/class/System.XML/System.Xml/XmlParserContext.cs index 5f452eaa7da..acd18bb957e 100644 --- a/mcs/class/System.XML/System.Xml/XmlParserContext.cs +++ b/mcs/class/System.XML/System.Xml/XmlParserContext.cs @@ -162,16 +162,16 @@ namespace System.Xml this.namespaceManager = nsMgr != null ? nsMgr : new XmlNamespaceManager (nameTable); if (dtd != null) { - this.docTypeName = dtd.Name; - this.publicID = dtd.PublicId; - this.systemID = dtd.SystemId; - this.internalSubset = dtd.InternalSubset; + this.DocTypeName = dtd.Name; + this.PublicId = dtd.PublicId; + this.SystemId = dtd.SystemId; + this.InternalSubset = dtd.InternalSubset; this.dtd = dtd; } this.encoding = enc; - this.baseURI = baseURI; - this.xmlLang = xmlLang; + this.BaseURI = baseURI; + this.XmlLang = xmlLang; this.xmlSpace = xmlSpace; contextItems = new ArrayList (); @@ -180,15 +180,15 @@ namespace System.Xml #region Fields - private string baseURI; - private string docTypeName; + private string baseURI = String.Empty; + private string docTypeName = String.Empty; private Encoding encoding; - private string internalSubset; + private string internalSubset = String.Empty; private XmlNamespaceManager namespaceManager; private XmlNameTable nameTable; - private string publicID; - private string systemID; - private string xmlLang; + private string publicID = String.Empty; + private string systemID = String.Empty; + private string xmlLang = String.Empty; private XmlSpace xmlSpace; private ArrayList contextItems; private int contextItemCount; @@ -200,12 +200,12 @@ namespace System.Xml public string BaseURI { get { return baseURI; } - set { baseURI = value; } + set { baseURI = value != null ? value : String.Empty; } } public string DocTypeName { get { return docTypeName != null ? docTypeName : dtd != null ? dtd.Name : null; } - set { docTypeName = value; } + set { docTypeName = value != null ? value : String.Empty; } } internal DTDObjectModel Dtd { @@ -220,7 +220,7 @@ namespace System.Xml public string InternalSubset { get { return internalSubset != null ? internalSubset : dtd != null ? dtd.InternalSubset : null; } - set { internalSubset = value; } + set { internalSubset = value != null ? value : String.Empty; } } public XmlNamespaceManager NamespaceManager { @@ -235,17 +235,17 @@ namespace System.Xml public string PublicId { get { return publicID != null ? publicID : dtd != null ? dtd.PublicId : null; } - set { publicID = value; } + set { publicID = value != null ? value : String.Empty; } } public string SystemId { get { return systemID != null ? systemID : dtd != null ? dtd.SystemId : null; } - set { systemID = value; } + set { systemID = value != null ? value : String.Empty; } } public string XmlLang { get { return xmlLang; } - set { xmlLang = value; } + set { xmlLang = value != null ? value : String.Empty; } } public XmlSpace XmlSpace { diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs index 5471ed84efa..e574a163672 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -98,12 +98,13 @@ namespace System.Xml public XmlTextReader (string url, XmlNameTable nt) { Uri uri = resolver.ResolveUri (null, url); + string uriString = uri != null ? uri.ToString () : String.Empty; Stream s = resolver.GetEntity (uri, null, typeof (Stream)) as Stream; XmlParserContext ctx = new XmlParserContext (nt, new XmlNamespaceManager (nt), String.Empty, XmlSpace.None); - this.InitializeContext (uri.ToString(), ctx, new XmlStreamReader (s), XmlNodeType.Document); + this.InitializeContext (uriString, ctx, new XmlStreamReader (s), XmlNodeType.Document); } public XmlTextReader (TextReader input, XmlNameTable nt) @@ -1307,32 +1308,41 @@ namespace System.Xml } for (int i = 0; i < attributeCount; i++) { - if (Object.ReferenceEquals (attributeTokens [i].Prefix, XmlNamespaceManager.PrefixXml)) { - string aname = attributeTokens [i].LocalName; - string value = attributeTokens [i].Value; - switch (aname) { - case "base": - if (this.resolver != null) - parserContext.BaseURI = resolver.ResolveUri (new Uri (BaseURI), value).ToString (); - else - parserContext.BaseURI = value; + if (!Object.ReferenceEquals (attributeTokens [i].Prefix, XmlNamespaceManager.PrefixXml)) + continue; + string aname = attributeTokens [i].LocalName; + string value = attributeTokens [i].Value; + switch (aname) { + case "base": + if (this.resolver != null) { + Uri buri = + BaseURI != String.Empty ? + new Uri (BaseURI) : null; + Uri uri = resolver.ResolveUri ( + buri, value); + parserContext.BaseURI = + uri != null ? + uri.ToString () : + String.Empty; + } + else + parserContext.BaseURI = value; + break; + case "lang": + parserContext.XmlLang = value; + break; + case "space": + switch (value) { + case "preserve": + parserContext.XmlSpace = XmlSpace.Preserve; break; - case "lang": - parserContext.XmlLang = value; - break; - case "space": - switch (value) { - case "preserve": - parserContext.XmlSpace = XmlSpace.Preserve; - break; - case "default": - parserContext.XmlSpace = XmlSpace.Default; - break; - default: - throw NotWFError (String.Format ("Invalid xml:space value: {0}", value)); - } + case "default": + parserContext.XmlSpace = XmlSpace.Default; break; + default: + throw NotWFError (String.Format ("Invalid xml:space value: {0}", value)); } + break; } } |