File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ package xmlquery
22
33import (
44 "encoding/xml"
5+ "io"
56)
67
7- type ParserOptions struct {
8+ type ParserOptions struct {
89 Decoder * DecoderOptions
910}
1011
@@ -17,14 +18,16 @@ func (options ParserOptions) apply(parser *parser) {
1718// DecoderOptions implement the very same options than the standard
1819// encoding/xml package. Please refer to this documentation:
1920// https://golang.org/pkg/encoding/xml/#Decoder
20- type DecoderOptions struct {
21- Strict bool
22- AutoClose []string
23- Entity map [string ]string
21+ type DecoderOptions struct {
22+ Strict bool
23+ AutoClose []string
24+ Entity map [string ]string
25+ CharsetReader func (charset string , input io.Reader ) (io.Reader , error )
2426}
2527
2628func (options DecoderOptions ) apply (decoder * xml.Decoder ) {
2729 decoder .Strict = options .Strict
2830 decoder .AutoClose = options .AutoClose
2931 decoder .Entity = options .Entity
32+ decoder .CharsetReader = options .CharsetReader
3033}
Original file line number Diff line number Diff line change @@ -69,7 +69,9 @@ func createParser(r io.Reader) *parser {
6969 level : 0 ,
7070 reader : reader ,
7171 }
72- p .decoder .CharsetReader = charset .NewReaderLabel
72+ if p .decoder .CharsetReader == nil {
73+ p .decoder .CharsetReader = charset .NewReaderLabel
74+ }
7375 p .prev = p .doc
7476 return p
7577}
You can’t perform that action at this time.
0 commit comments