Ignore comments at the top of XML files (#27176)

Allows comments to be at the top of Fleet XML CSP files (addresses
https://github.com/fleetdm/fleet/issues/26443)

We should validate that this fixes the errors with GitOps pushes, but I
don't know how to do that without pushing this change through to QA.

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files)
for more information.
- [x] Added/updated automated tests
- [x] Manual QA for all new/changed functionality
This commit is contained in:
Dan Tsekhanskiy
2025-03-15 10:40:50 -05:00
committed by GitHub
parent 3679471a99
commit f63afc8253
3 changed files with 6 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
* Allow for any number of comments at the top of XML files for Windows MDM profile CSPs
+3
View File
@@ -96,6 +96,9 @@ func (m *MDMWindowsConfigProfile) ValidateUserProvided() error {
case xml.ProcInst:
return errors.New("The file should include valid XML: processing instructions are not allowed.")
case xml.Comment:
continue
case xml.StartElement:
switch t.Name.Local {
case "Replace", "Add":
+2
View File
@@ -411,7 +411,9 @@ func TestValidateUserProvided(t *testing.T) {
profile: MDMWindowsConfigProfile{
SyncML: []byte(`
<!-- this is a comment -->
<!-- this is another comment -->
<Replace>
<!-- this is a comment inside replace -->
<Target>
<LocURI>Custom/URI</LocURI>
</Target>