Sitelet https://github.com/DiscUtils/DiscUtils/pull/31
Skip to content

Don't attempt to parse the DTD for Plist files - #31

Merged
LordMike merged 2 commits into
DiscUtils:masterfrom
qmfrederik:fixes/dmg
Aug 16, 2017
Merged

LordMike merged 2 commits into
DiscUtils:masterfrom
qmfrederik:fixes/dmg

Conversation

@qmfrederik

Copy link
Copy Markdown
Contributor

The Plist class parses Apple Property List files. These files come with a DTD declaration.

DTD processing is now prohibited by default in .NET 4.0 and above, but is still enabled (requested) unless you explicitly disable it. This would result in an exception when parsing property list files (for example, when opening DMG images).

This PR disables DTD processing alltogether and adds a unit test for the property list parsing code.

@qmfrederik
qmfrederik requested a review from LordMike June 25, 2017 21:41
@qmfrederik

Copy link
Copy Markdown
Contributor Author

@LordMike Can you take a look at this? Thanks!

@zivillian

Copy link
Copy Markdown
Contributor

The default value of ProhibitDtd in XmlReaderSettings is true

so just passing a new instance of XmlReaderSettings to XmlReader.Create would be more "efficient", but your solution seems to be more specific about the desired settings.

In .NET Framework version 4.0 [...] The ProhibitDtd property has been deprecated

If I'm correct, your change would introduce a compiler warning.

you can set the DtdProcessing property to Ignore, which will [...] simply skip over it and not process it

I guess this is what you intended for .NET > 4.0.

(I haven't tested this and the linked documentation mentions only a beta version, so this might be incorrect.)

@LordMike

Copy link
Copy Markdown
Member

Totally forgot about this one.

Will we ever encounter PList files that use custom entities?

Would it be better to let DtdProcessing be an option the user sets, through some settings object?

@qmfrederik

Copy link
Copy Markdown
Contributor Author

@zivillian I perhaps misunderstood your comment; but this PR is not changing the value of ProhibitDtd; but it is setting DtdProcessing to Ignore on .NET 4 and above.

@qmfrederik

Copy link
Copy Markdown
Contributor Author

@LordMike

Will we ever encounter PList files that use custom entities?

I'm fairly sure that we will never encounter a Plist file with custom entities. Plist files can be serialized in various formats, XML being one of them. Plist doesn't have the notion of entities so you will not see any entities in the XML files generated by XML.

Would it be better to let DtdProcessing be an option the user sets, through some settings object?

Basically, on .NET 4.0 and above (this includes Core), DtdProcessing is always prohibited, so it must be set to Ignore, otherwise it won't work. You will never want to do DTD processing on Plist files, so I don't think there is any value to letting the user change that value.

@qmfrederik

Copy link
Copy Markdown
Contributor Author

@LordMike @zivillian Back from vacation, rebased the PR, the build now passes, let me know if this is good to go.

@zivillian

Copy link
Copy Markdown
Contributor

@qmfrederik It looks like I've misread your code - judging the comments and the changes this should be fine.

@LordMike

Copy link
Copy Markdown
Member

@qmfrederik put a note in the ifdef where you set the DtdIgnore property explaining that i MUST be set to Ignore on anything by net20. Then it should be good to go.


XmlReaderSettings settings = new XmlReaderSettings();
#if !NET20
settings.DtdProcessing = DtdProcessing.Ignore;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a note here, explaining that i MUST be set to Ignore on anything by net20. Then it should be good to go.

@qmfrederik

Copy link
Copy Markdown
Contributor Author

@LordMike Should be good to go now ;-)

@LordMike
LordMike merged commit 77f67c6 into DiscUtils:master Aug 16, 2017
LordMike added a commit that referenced this pull request Aug 16, 2017
Includes PRs:
#17, #18, #21, #22, #23, #27, #30, #31, #33, #34, #35, #36, #38, #39, #40, #41, #48, #51, #52, #55, #60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants