Fix Microsoft UTF16 endianness. (#29708)

Fixes #28488

Microsoft uses UTF16LE and not UTF16BE

# Checklist for submitter
- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
- [x] Added/updated automated tests
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Herman Slatman <hslatman@users.noreply.github.com>
This commit is contained in:
Victor Lyuboslavsky
2025-06-04 12:02:28 -06:00
committed by GitHub
co-authored by Herman Slatman
parent 0f1779fb5b
commit 2d24008091
3 changed files with 5 additions and 4 deletions
+1
View File
@@ -0,0 +1 @@
Fixed issue where NDES SCEP admin page was parsed using wrong UTF16 endianness.
+3 -3
View File
@@ -239,9 +239,9 @@ func (s *SCEPConfigService) GetNDESSCEPChallenge(ctx context.Context, proxy flee
resp.StatusCode)})
}
// Make a transformer that converts MS-Win default to UTF8:
win16be := unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM)
// Make a transformer that is like win16be, but abides by BOM:
utf16bom := unicode.BOMOverride(win16be.NewDecoder())
win16le := unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM)
// Make a transformer that is like win16le, but abides by BOM:
utf16bom := unicode.BOMOverride(win16le.NewDecoder())
// Make a Reader that uses utf16bom:
unicodeReader := transform.NewReader(resp.Body, utf16bom)
+1 -1
View File
@@ -70,7 +70,7 @@ func TestValidateNDESSCEPAdminURL(t *testing.T) {
require.NoError(t, err)
byteData := make([]byte, len(datUTF16)*2)
for i, v := range datUTF16 {
binary.BigEndian.PutUint16(byteData[i*2:], v)
binary.LittleEndian.PutUint16(byteData[i*2:], v)
}
return byteData
}