osv-scanner icon indicating copy to clipboard operation
osv-scanner copied to clipboard

Unexpected diff when writing XML

Open cuixq opened this issue 1 year ago • 4 comments

Texts are escaped to 	 when we write XML in Maven updater. Go does escaping in EncodeToken: https://github.com/golang/go/blob/master/src/encoding/xml/marshal.go#L223

cuixq avatar Aug 16 '24 05:08 cuixq

Not only tabs are escaped but also other characters: https://github.com/golang/go/blob/master/src/encoding/xml/xml.go#L1916

cuixq avatar Aug 21 '24 05:08 cuixq

Besides the escaped texts, due to issue https://github.com/golang/go/issues/21399 self-closing tags are not encoded as expected.

We may consider refactoring how to write XMLs: instead of calling xml.Encode(), write the content directly to avoid unexpected behaviour.

cuixq avatar Aug 26 '24 04:08 cuixq

Are there remaining issues to track here, or can we close this @cuixq ?

oliverchang avatar Sep 18 '24 05:09 oliverchang

I noticed one issue of multiple-line self-closing tag encoded into one line:

<a 
something
something />

is now

<a something something />

this seems low priority though.

cuixq avatar Sep 18 '24 06:09 cuixq

Going to track this in separate issues.

cuixq avatar Jan 13 '25 01:01 cuixq