Browse Source

Fixed unhandled FileNotFoundException in XML tree editor when a file is loaded with a dtd reference that cannot be found.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3886 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
a5c7b72482
  1. 1
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeEditor.cs
  2. 59
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/LoadXmlFileWithMissingDtdFileRefTestFixture.cs
  3. 1
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

1
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeEditor.cs

@ -40,6 +40,7 @@ namespace ICSharpCode.XmlEditor @@ -40,6 +40,7 @@ namespace ICSharpCode.XmlEditor
{
try {
document = new XmlDocument();
document.XmlResolver = null;
document.LoadXml(xml);
view.Document = document;
} catch (XmlException ex) {

59
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/LoadXmlFileWithMissingDtdFileRefTestFixture.cs

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
using System.Xml;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Tree
{
/// <summary>
/// If the XML loaded contains a DTD reference then if the XmlDocument.XmlResolver is not
/// set to null then the XmlTreeEditor will throw an unhandled FileNotFoundException.
/// </summary>
[TestFixture]
public class LoadXmlFileWithMissingDtdFileRefTestFixture : XmlTreeViewTestFixtureBase
{
[SetUp]
public void Init()
{
base.InitFixture();
}
[Test]
public void RootElementIsLoaded()
{
Assert.AreEqual("Library", editor.Document.DocumentElement.Name);
}
/// <summary>
/// Returns the xhtml strict schema as the default schema.
/// </summary>
protected override XmlSchemaCompletionData DefaultSchemaCompletionData {
get {
XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema();
return new XmlSchemaCompletionData(reader);
}
}
protected override string GetXml()
{
return "<!DOCTYPE Library SYSTEM \"Library.dtd\">\r\n" +
"<Library> \r\n" +
" <Book ISBN=\"9999-44-44-3333\" > \r\n" +
" <Title>SharpDevelop</Title> \r\n" +
" <Author>abc</Author>\r\n" +
" <Publisher>SharpDevelop Publications</Publisher>\r\n" +
" <Date_Published>22/10/1999</Date_Published>\r\n" +
" </Book>\r\n" +
"</Library>";
}
}
}

1
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

@ -81,6 +81,7 @@ @@ -81,6 +81,7 @@
<Compile Include="Tree\EditCommentNodesTestFixture.cs" />
<Compile Include="Tree\InsertTextNodeAfterTestFixture.cs" />
<Compile Include="Tree\InsertTextNodeBeforeTestFixture.cs" />
<Compile Include="Tree\LoadXmlFileWithMissingDtdFileRefTestFixture.cs" />
<Compile Include="Tree\MenuCommandsTestFixture.cs" />
<Compile Include="Tree\MouseDownTestFixture.cs" />
<Compile Include="Tree\OwnerStatusTestFixture.cs" />

Loading…
Cancel
Save