decoder_test.go 691 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2019 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package xml // import "miniflux.app/reader/xml"
  5. import (
  6. "encoding/xml"
  7. "fmt"
  8. "strings"
  9. "testing"
  10. )
  11. func TestIllegalCharacters(t *testing.T) {
  12. type myxml struct {
  13. XMLName xml.Name `xml:"rss"`
  14. Version string `xml:"version,attr"`
  15. Title string `xml:"title"`
  16. }
  17. data := fmt.Sprintf(`<?xml version="1.0" encoding="windows-1251"?><rss version="2.0"><title>%s</title></rss>`, "\x10")
  18. var x myxml
  19. decoder := NewDecoder(strings.NewReader(data))
  20. err := decoder.Decode(&x)
  21. if err != nil {
  22. t.Error(err)
  23. }
  24. }