mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Improve XML decoder to remove illegal characters
This commit is contained in:
parent
7409bba0d8
commit
2eb2441f2b
7 changed files with 85 additions and 19 deletions
29
reader/xml/decoder_test.go
Normal file
29
reader/xml/decoder_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2019 Frédéric Guillot. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package xml // import "miniflux.app/reader/xml"
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIllegalCharacters(t *testing.T) {
|
||||
type myxml struct {
|
||||
XMLName xml.Name `xml:"rss"`
|
||||
Version string `xml:"version,attr"`
|
||||
Title string `xml:"title"`
|
||||
}
|
||||
|
||||
data := fmt.Sprintf(`<?xml version="1.0" encoding="windows-1251"?><rss version="2.0"><title>%s</title></rss>`, "\x10")
|
||||
var x myxml
|
||||
|
||||
decoder := NewDecoder(strings.NewReader(data))
|
||||
err := decoder.Decode(&x)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue