Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems using XmlPeek and XmlPoke in XML files with DOCTYPE #930

Closed
fabionuno opened this issue May 28, 2016 · 3 comments
Closed

Problems using XmlPeek and XmlPoke in XML files with DOCTYPE #930

fabionuno opened this issue May 28, 2016 · 3 comments
Labels
Milestone

Comments

@fabionuno
Copy link
Contributor

What You Are Seeing?

I can't use XmlPeek and XmlPoke in XML files with a DOCTYPE declaration

What is Expected?

These methods should be able to work with XML files with DOCTYPE declaration

What version of Cake are you using?

0.12.0

Are you running on a 32 or 64 bit system?

64 bit

What environment are you running on? Windows? Linux? Mac?

OS X 10.11.5

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDisplayName</key>
    <string>Cake</string>
</dict>
</plist>
var target = Argument("target", "Default");

Task("Default")
.Does(()=>
{
    var xmlFile = new FilePath(@"doctype.xml");
    var xpath = "/plist/dict/key[text()='CFBundleIdentifier']/following-sibling::string[1]";
    XmlPeek(xmlFile, xpath);
});

RunTarget(target);

Output Log

Compiling build script...
unknown.cake (512,38): `Cake.Common.Tools.DNU.DNUAliases.DNURestore(this Cake.Core.ICakeContext)' is obsolete: `Please use DotNetCoreRestore() instead.'
unknown.cake (519,38): `Cake.Common.Tools.DNU.DNUAliases.DNURestore(this Cake.Core.ICakeContext, Cake.Core.IO.FilePath)' is obsolete: `Please use DotNetCoreRestore(string) instead.'
unknown.cake (526,38): `Cake.Common.Tools.DNU.DNUAliases.DNURestore(this Cake.Core.ICakeContext, Cake.Common.Tools.DNU.Restore.DNURestoreSettings)' is obsolete: `Please use DotNetCoreRestore(DotNetCoreRestoreSettings) instead.'
unknown.cake (533,38): `Cake.Common.Tools.DNU.DNUAliases.DNURestore(this Cake.Core.ICakeContext, Cake.Core.IO.FilePath, Cake.Common.Tools.DNU.Restore.DNURestoreSettings)' is obsolete: `Please use DotNetCoreRestore(string, DotNetCoreRestoreSettings) instead.'
unknown.cake (540,38): `Cake.Common.Tools.DNU.DNUAliases.DNUBuild(this Cake.Core.ICakeContext, string)' is obsolete: `Please use DotNetCoreBuild(string) instead.'
unknown.cake (547,38): `Cake.Common.Tools.DNU.DNUAliases.DNUBuild(this Cake.Core.ICakeContext, string, Cake.Common.Tools.DNU.Build.DNUBuildSettings)' is obsolete: `Please use DotNetCoreBuild(string, DotNetCoreBuildSettings) instead.'
unknown.cake (554,38): `Cake.Common.Tools.DNU.DNUAliases.DNUPack(this Cake.Core.ICakeContext, string)' is obsolete: `Please use DotNetCorePack(string) instead.'
unknown.cake (561,38): `Cake.Common.Tools.DNU.DNUAliases.DNUPack(this Cake.Core.ICakeContext, string, Cake.Common.Tools.DNU.Pack.DNUPackSettings)' is obsolete: `Please use DotNetCorePack(string, DotNetCorePackSettings) instead.'
unknown.cake (1726,43): `Cake.Common.Xml.XmlPokeAliases.XmlPoke(this Cake.Core.ICakeContext, string, string, string)' is obsolete: `Please use XmlPokeString(string, string, string) instead.'
unknown.cake (1733,43): `Cake.Common.Xml.XmlPokeAliases.XmlPoke(this Cake.Core.ICakeContext, string, string, string, Cake.Common.Xml.XmlPokeSettings)' is obsolete: `Please use XmlPokeString(string, string, string, XmlPokeSettings) instead.'

========================================
Default
========================================
Executing task: Default
An error occured when executing task 'Default'.
Error: System.Xml.XmlException: For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
  at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) <0x39efa70 + 0x0007f> in <filename unknown>:0 
  at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo (System.String res) <0x39ef678 + 0x0006f> in <filename unknown>:0 
  at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl () <0x39ef338 + 0x0003f> in <filename unknown>:0 
  at System.Xml.XmlTextReaderImpl.ParseDocumentContent () <0x39ee570 + 0x002a7> in <filename unknown>:0 
  at System.Xml.XmlTextReaderImpl.Read () <0x39e9de8 + 0x00053> in <filename unknown>:0 
  at System.Xml.XmlLoader.LoadDocSequence (System.Xml.XmlDocument parentDoc) <0x39ecf60 + 0x00038> in <filename unknown>:0 
  at System.Xml.XmlLoader.Load (System.Xml.XmlDocument doc, System.Xml.XmlReader reader, Boolean preserveWhitespace) <0x39e95b8 + 0x001a3> in <filename unknown>:0 
  at System.Xml.XmlDocument.Load (System.Xml.XmlReader reader) <0x39e9450 + 0x00083> in <filename unknown>:0 
  at Cake.Common.Xml.XmlPeekAliases.XmlPeek (System.Xml.XmlReader source, System.String xpath, Cake.Common.Xml.XmlPeekSettings settings) <0x39e8aa0 + 0x00099> in <filename unknown>:0 
  at Cake.Common.Xml.XmlPeekAliases.XmlPeek (ICakeContext context, Cake.Core.IO.FilePath filePath, System.String xpath, Cake.Common.Xml.XmlPeekSettings settings) <0x39e4ce0 + 0x000b7> in <filename unknown>:0 
  at Cake.Common.Xml.XmlPeekAliases.XmlPeek (ICakeContext context, Cake.Core.IO.FilePath filePath, System.String xpath) <0x39e4c18 + 0x00047> in <filename unknown>:0 
  at CakeBuildScriptImpl.XmlPeek (Cake.Core.IO.FilePath filePath, System.String xpath) <0x39e4bd8 + 0x0002b> in <filename unknown>:0 
  at CakeBuildScriptImpl.<Execute>m__0 () <0x39e4b78 + 0x0004b> in <filename unknown>:0 
  at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass4.<Does>b__3 (ICakeContext context) <0x39e4b58 + 0x00014> in <filename unknown>:0 
  at Cake.Core.ActionTask.Execute (ICakeContext context) <0x39e4aa0 + 0x00059> in <filename unknown>:0 
  at Cake.Core.DefaultExecutionStrategy.Execute (Cake.Core.CakeTask task, ICakeContext context) <0x39e4850 + 0x00162> in <filename unknown>:0 
  at Cake.Core.CakeEngine.ExecuteTask (ICakeContext context, IExecutionStrategy strategy, System.Diagnostics.Stopwatch stopWatch, Cake.Core.CakeTask task, Cake.Core.CakeReport report) <0x39e4258 + 0x00099> in <filename unknown>:0 
@fabionuno
Copy link
Contributor Author

To solve this problem I have added two properties, DtdProcessing and ValidationType to XmlPeekSettings and XmlPokeSettings class.
These values are used to construct a XmlReaderSettings that will be used in XmlReader.Create to define how the reader will process the DTDs.

If you are interested i can do a PR with this code.

@devlead
Copy link
Member

devlead commented May 29, 2016

@fabionuno A PR would be appreciated 👍

@devlead
Copy link
Member

devlead commented Jun 3, 2016

Fixed by #939

@devlead devlead closed this as completed Jun 3, 2016
@patriksvensson patriksvensson changed the title I can't use XmlPeek and XmlPoke in XML files with DOCTYPE Problems using XmlPeek and XmlPoke in XML files with DOCTYPE Jun 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants