Compare commits

...

2 Commits

2 changed files with 21 additions and 3 deletions

View File

@ -34,12 +34,12 @@ func (c *Category) Check() error {
if c.Scheme != "" {
if !isValidURI(c.Scheme) {
return fmt.Errorf("scheme attribute of category %v not correctly formatted", c.Scheme)
return fmt.Errorf("scheme attribute %v of category not correctly formatted", c.Scheme)
}
}
if !isCorrectlyEscaped(c.Label) {
return fmt.Errorf("label attribute of category %v not correctly escaped", c.Label)
return fmt.Errorf("label attribute %v of category not correctly escaped", c.Label)
}
if c.Content == nil {

View File

@ -1,6 +1,10 @@
package atomfeed
import "errors"
import (
"errors"
"fmt"
"html"
)
type Generator struct {
*CommonAttributes
@ -9,10 +13,24 @@ type Generator struct {
Text string `xml:"text"`
}
func NewGenerator(text string) *Generator {
return &Generator{Text: html.UnescapeString(text)}
}
func (g *Generator) Check() error {
if g.URI != "" {
if !isValidURI(g.URI) {
return fmt.Errorf("uri attribute %v of generator not correctly formatted", g.URI)
}
}
if g.Text == "" {
return errors.New("text element of generator empty")
}
if !isCorrectlyEscaped(g.Text) {
return fmt.Errorf("text element %v of generator not correctly escaped", g.Text)
}
return nil
}