Force undefined content of category and link to be empty or valid xml
This commit is contained in:
10
category.go
10
category.go
@@ -16,6 +16,10 @@ type Category struct {
|
||||
|
||||
// NewCategory creates a new Category. It returns a *Category and an error.
|
||||
func NewCategory(term, content string) (*Category, error) {
|
||||
if !isValidXML(content) {
|
||||
return nil, fmt.Errorf("%v not valid XML", content)
|
||||
}
|
||||
|
||||
return &Category{Term: term, Content: content}, nil
|
||||
}
|
||||
|
||||
@@ -41,8 +45,10 @@ func (c *Category) Check() error {
|
||||
return fmt.Errorf("label attribute %v of category not correctly escaped", c.Label)
|
||||
}
|
||||
|
||||
if c.Content == "" {
|
||||
return errors.New("content element of category empty")
|
||||
if c.Content != "" {
|
||||
if !isValidXML(c.Content) {
|
||||
return fmt.Errorf("content element %v of category not valid XML", c.Content)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user