Diable schema validation in ScriptWriter.cs (#3679)

This commit is contained in:
Dongbo Wang 2017-05-02 09:40:53 -07:00 committed by GitHub
parent 73e5dc3020
commit 52336b8fda

View file

@ -47,6 +47,10 @@ namespace Microsoft.PowerShell.Cmdletization
ScriptWriter.s_xmlReaderSettings.MaxCharactersFromEntities = 16384; // generous guess for the upper bound
ScriptWriter.s_xmlReaderSettings.MaxCharactersInDocument = 128 * 1024 * 1024; // generous guess for the upper bound
#if CORECLR // The XML Schema file 'cmdlets-over-objects.xsd' is missing in Github, and it's likely the resource string
//'CmdletizationCoreResources.Xml_cmdletsOverObjectsXsd' needs to be reworked to work in .NET Core.
ScriptWriter.s_xmlReaderSettings.DtdProcessing = DtdProcessing.Ignore;
#else
ScriptWriter.s_xmlReaderSettings.DtdProcessing = DtdProcessing.Parse; // Allowing DTD parsing with limits of MaxCharactersFromEntities/MaxCharactersInDocument
ScriptWriter.s_xmlReaderSettings.XmlResolver = null; // do not fetch external documents
// xsd schema related settings
@ -58,6 +62,7 @@ namespace Microsoft.PowerShell.Cmdletization
ScriptWriter.s_xmlReaderSettings.Schemas = new XmlSchemaSet();
ScriptWriter.s_xmlReaderSettings.Schemas.Add(null, cmdletizationSchemaReader);
ScriptWriter.s_xmlReaderSettings.Schemas.XmlResolver = null; // do not fetch external documents
#endif
}
#endregion Static code reused for reading cmdletization xml