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

REXML don't support UTF8 BOM on Windows 11 #231

Open
andryua opened this issue Jan 9, 2025 · 6 comments
Open

REXML don't support UTF8 BOM on Windows 11 #231

andryua opened this issue Jan 9, 2025 · 6 comments

Comments

@andryua
Copy link

andryua commented Jan 9, 2025

Hi!

After update Puppet aggent to 8.9.0 (they updated REXML from 3.2.5 to 3.3.6 version) - puppet chocolatey provider can't use correct parsing XML witn UTF-8 BOM codding. Only if enable support beta UTF8 WordWide in Windows 10/11 - everything work fine. If disable this feature - puppet send error again. (tried on cyrrilic and english - same issues)

Debug: Gathering sources from 'C:\ProgramData\chocolatey\config\chocolatey.config'.
Error: Could not prefetch chocolateysource provider 'windows': Malformed XML: Content at the start of the document (got '')
Line: 1
Position: 47
Last 80 unconsumed characters:
<?xml version="1.0" encoding="utf-8"?>
Warning: /Stage[main]/Windows::Chocolatey/Chocolateysource[chocolatey]: Skipping because provider prefetch failed
Debug: /Stage[main]/Windows::Chocolatey/Chocolateysource[chocolatey]: Resource is being skipped, unscheduling all events
@andryua andryua changed the title REXML don't support UTF8 with BOM on Windows 11 REXML don't support UTF8 BOM on Windows 11 Jan 9, 2025
@naitoh
Copy link
Contributor

naitoh commented Jan 9, 2025

I think REXML supports UTF-8 with BOM.

rexml/lib/rexml/source.rb

Lines 193 to 194 in b70388c

elsif @scanner.scan(/\xef\xbb\xbf/n)
detected_encoding = "UTF-8"

@andryua

Could you give us an XML file that can reproduce this problem?

@andryua
Copy link
Author

andryua commented Jan 9, 2025

@andryua
Copy link
Author

andryua commented Jan 9, 2025

if i install last version of Puppet and replace REXML tool from 3.3.6 on other older (3.2.6 or 3.2.5) - all works. if I replace on 3.2.7 and newer - puppet send errors. (UTF8 WorldWide support - disabled!)

@naitoh
Copy link
Contributor

naitoh commented Jan 9, 2025

I can't seem to reproduce this in my m1 Mac environment...

$ ruby -v
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin22]
$ gem list rexml
*** LOCAL GEMS ***

rexml (3.3.6)
$ ruby -r "rexml/document" -e 'REXML::Document.new(File.open("./chocolatey.txt"))' 

@andryua
Copy link
Author

andryua commented Jan 9, 2025

on Windows 11 or 10 any build!!!

@andryua
Copy link
Author

andryua commented Jan 10, 2025

and try not File.open - try File.read (same using puppetlabs-chocolatey in their code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants