Force undefined content of category and link to be empty or valid xml
This commit is contained in:
10
link.go
10
link.go
@@ -19,6 +19,10 @@ type Link struct {
|
||||
|
||||
// NewLink creates a new Link. It returns a *Link and an error.
|
||||
func NewLink(href, content string) (*Link, error) {
|
||||
if !isValidXML(content) {
|
||||
return nil, fmt.Errorf("%v not valid XML", content)
|
||||
}
|
||||
|
||||
return &Link{Href: IRI(href), Content: content}, nil
|
||||
}
|
||||
|
||||
@@ -51,8 +55,10 @@ func (l *Link) Check() error {
|
||||
}
|
||||
}
|
||||
|
||||
if l.Content == "" {
|
||||
return errors.New("content element of link empty")
|
||||
if l.Content != "" {
|
||||
if !isValidXML(l.Content) {
|
||||
return fmt.Errorf("content element %v of link not valid XML", l.Content)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user