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

Improve heuristic for XML property lists #6119

Merged
merged 1 commit into from
Oct 19, 2022
Merged

Conversation

Alhadis
Copy link
Collaborator

@Alhadis Alhadis commented Oct 15, 2022

Description

Some XML property lists lack a <!DOCTYPE[^1] and/or XML signature[^2], and neither omission impacts the file's well-formedness (according to Xcode). Apparently, the only hard requirement is well-formed—though not necessarily valid—XML syntax.

This PR amends the heuristic for XML property list so it matches .plist files that:

  1. contain a line comprised wholly of <plist> (with or without a version attribute),
  2. contain an XML signature, which is invalid syntax in OpenStep property lists, or
  3. contain a line beginning with <!DOCTYPE plist.

Case 1 could extend to other data-type tags as well (especially <array> and <dict>), but the grammar we're using highlights such tags as invalid when they appear outside of a <plist> element:

Example 1: <array>
<array>
	<string>/usr/local/bin</string>
	<string>/usr/bin</string>
	<string>/bin</string>
	<string>/usr/sbin</string>
	<string>/sbin</string>
</array>
Example 2: <dict>
<dict>
	<key>kubernetes.docker.internal</key>
	<string>127.0.0.1</string>
	<key>localhost</key>
	<array>
		<string>127.0.0.1</string>
		<string>::1</string>
	</array>
	<key>broadcasthost</key>
	<string>255.255.255.255</string>
</dict>

Checklist

(Template removed as it doesn't apply)

Sample files

File Source License
ff-man.plist Apple's fork of man(1) GPL v2
man.plist
info.min.plistCopied from local installation of cool-retro-term3 GPL v3+

Footnotes

  1. https://github.com/apple-oss-distributions/man/blob/54b31db2a21b33fe587826dbce22bac7ac775dce/ff-man.plist

  2. https://github.com/apple-oss-distributions/man/blob/54b31db2a21b33fe587826dbce22bac7ac775dce/man.plist

  3. Specifically, /Applications/cool-retro-term.app/Contents/Info.plist. Newlines were stripped in order to assert that XML declaration matching is working.

@Alhadis Alhadis requested a review from a team as a code owner October 15, 2022 10:55
@Alhadis Alhadis requested a review from lildude October 15, 2022 10:55
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

@Alhadis Alhadis merged commit 0f17801 into master Oct 19, 2022
@Alhadis Alhadis deleted the fix-plist-heuristic branch October 19, 2022 04:31
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants