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

proposal: encoding/xml: ignore invalid characters when Decoder.Strict is false #62217

Open
ear7h opened this issue Aug 22, 2023 · 1 comment
Open
Labels
Milestone

Comments

@ear7h
Copy link

ear7h commented Aug 22, 2023

My particular problem would be solved by checkingDecoder.Strict here:

if !isInCharacterRange(r) {

Alternatively, all character validation (including UTF-8) could be ignored and let Go's 0xfffd take over if a user ever wants a string from StringData.

for len(buf) > 0 {

@ear7h ear7h added the Proposal label Aug 22, 2023
@gopherbot gopherbot added this to the Proposal milestone Aug 22, 2023
@k3wio
Copy link

k3wio commented Oct 13, 2023

I'm very new to Go, but it seems that this would be contrary to the ideals of compatibility. I think adding a decoder setting, perhaps decoder.IgnoreInvalidCharacters (defaulting to false) would be a better path. This would enable the desired behavior without impacting existing code.

After adding the setting, the condition would become if !d.IgnoreInvalidCharacters && !isInCharacterRange(r)

if !isInCharacterRange(r) {

Possible example:
https://github.com/k3wio/go/blob/6e73de403d0648e59a4bfb142d8c6a151637a52d/src/encoding/xml/xml.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

3 participants