Skip to content

New XML PropertyListDecoder parser accepts malformed tags #1180

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

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

kperryua
Copy link
Contributor

A mistake was made during translation of PropertyListSerialization XML parsing to native PropertyListDecoder with regard to open tags.

PropertyListSerialization accepts open tags that look like any of the following:

`<` <VALIDTAG> `>`
`<` <VALIDTAG> `/` `>`
`<` <VALIDTAG> <WHITESPACE> <ANYTHING> `>`

The latter case is to handle tags with attributes, which are typically only used on the plist tag, e.g. <plist version="1.0">.

The adapted code was too permissive and accepted:

`<` <VALIDTAG> <ANYTHING> `>`
`<` <VALIDTAG> <ANYTHING> `/` `>`

Which means we accepted input like:

<stringGARBAGE>foo</string>

This PR fixes that by checking the next character after a valid tag name before accepting it.

@kperryua kperryua requested a review from jmschonfeld February 18, 2025 19:37
@jmschonfeld
Copy link
Contributor

@swift-ci please test

@kperryua kperryua merged commit 8a7adf2 into swiftlang:main Feb 18, 2025
2 of 3 checks passed
jmschonfeld added a commit that referenced this pull request Feb 20, 2025
#1180 accidentally introduces a build issue on macOS due to new ambiguity between Foundation.String.Encoding and FoundationEssentials.String.Encoding but we weren't able to detect that since macOS CI is currently nonfunctional. This fixes the ambiguity using the same trick we use elsewhere in our unit tests. I've validated locally that this fixes the build issues on macOS.
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.

2 participants