Bug 26173 - XmlFilterReader does not respect DtdProcessing enum
Summary: XmlFilterReader does not respect DtdProcessing enum
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2015-01-19 15:45 UTC by Aaron Bockover [MSFT]
Modified: 2015-03-17 16:45 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Aaron Bockover [MSFT] 2015-01-19 15:45:57 UTC
XmlFilterReader (used by Document) only checks for XmlTextReader.ProhibitDtd and not XmlTextReader.DtdProcessing. ProhibitedDtd has been obsoleted in favor of DtdProcessing. Setting XmlTextReader.DtdProcessing to DtdProcessing.Ignore results in an exception when a DTD is encountered:

	var reader = new XmlTextReader (stream) {
	DtdProcessing = DtdProcessing.Ignore
	};
	XDocument.Load (reader);

System.Exception: Invalid platform ---> System.Xml.XmlException: Document Type Definition (DTD) is prohibited in this XML reader.
  at Mono.Xml.XmlFilterReader.Read () [0x00000] in <filename unknown>:0
  at Mono.Xml.XmlFilterReader.Read () [0x00000] in <filename unknown>:0
  at System.Xml.Linq.XDocument.ReadContent (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
  at System.Xml.Linq.XDocument.LoadCore (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
  at System.Xml.Linq.XDocument.Load (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
  at System.Xml.Linq.XDocument.Load (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0

The following is used as a workaround just after instantiating the XmlTextReader to skip to the first element node:

	while (reader.Read () && reader.NodeType != XmlNodeType.Element);

The check should be corrected here to check for 
https://github.com/mono/mono/blob/master/mcs/class/System.XML/Mono.Xml/XmlFilterReader.cs#L235
Comment 2 Atsushi Eno 2015-01-20 00:48:23 UTC
Set XmlResolver = null to avoid DTD resolution so far.
Comment 3 Atsushi Eno 2015-03-17 16:45:08 UTC
We are now referencesource based so it should work too.