Skip to content

Fix(XML): Sanitize invalid char#182

Merged
Rom1-B merged 8 commits into
mainfrom
fix_sanitiaz_invalid_char
Jun 3, 2026
Merged

Fix(XML): Sanitize invalid char#182
Rom1-B merged 8 commits into
mainfrom
fix_sanitiaz_invalid_char

Conversation

@stonebuzz
Copy link
Copy Markdown
Contributor

@stonebuzz stonebuzz commented Jun 2, 2026

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

SCCM stores certain metadata in fixed-length NCHAR database fields. In some cases, these fields may contain trailing null bytes, residual binary data, or Unicode non-characters such as U+FFFE and U+FFFF. When this data is exported into XML files, it can introduce characters that are not valid according to the XML 1.0 specification.

As a result, the inventory import or push process may fail with an XML parsing error, preventing successful processing of the generated file.

Example of a corrupted value observed in production environments:

<PUBLISHER>Intel(R) Corporation쩗ኮ᠀耀��</PUBLISHER>

And should be

<PUBLISHER>Intel(R) Corporation쩗ኮ᠀耀��</PUBLISHER>

In this example, unexpected trailing characters are appended to the publisher name. These characters originate from corrupted or improperly sanitized database content and generate invalid XML output, leading to parsing failures during downstream processing.

Fixes #181

Screenshots (if appropriate):

@stonebuzz stonebuzz force-pushed the fix_sanitiaz_invalid_char branch from bc8b7b1 to bdba55d Compare June 2, 2026 14:08
@stonebuzz stonebuzz self-assigned this Jun 2, 2026
@stonebuzz stonebuzz added the bug label Jun 2, 2026
@tolemac
Copy link
Copy Markdown
Contributor

tolemac commented Jun 3, 2026

@stonebuzz the xml file is now ok:
image

Text: <PUBLISHER>Intel(R) Corporation쩗ኮ᠀耀</PUBLISHER>

xmlvalidation tell me "no errors were found" in file.

But the error continue, the sccm.log says:

2026-06-03 08:44:31 [473@SUInventario]
[Config 1] Can't load file: /var/lib/glpi/_plugins/sccm/xml/1/16797877.ocs
An error occurred

I have launch several times and I have ensure the new file is generated but error persists..

@stonebuzz
Copy link
Copy Markdown
Contributor Author

@tolemac
can you retry ?

best regards

@tolemac
Copy link
Copy Markdown
Contributor

tolemac commented Jun 3, 2026

👍 done!! [Config 1] Push OK - 16797877

Good job, now this work fine!

@stonebuzz stonebuzz requested a review from Rom1-B June 3, 2026 10:24
Comment thread tests/PluginSccmSccmTest.php Outdated
Comment thread tests/PluginSccmSccmTest.php Outdated
stonebuzz and others added 2 commits June 3, 2026 14:21
Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
@stonebuzz stonebuzz requested a review from Rom1-B June 3, 2026 12:27
@Rom1-B Rom1-B merged commit 552e94c into main Jun 3, 2026
3 checks passed
@Rom1-B Rom1-B deleted the fix_sanitiaz_invalid_char branch June 3, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problems with characteres in the .ocs file

3 participants