Compare commits
2 Commits
f27116930a
...
566227773e
Author | SHA1 | Date | |
---|---|---|---|
566227773e | |||
92d71fdbde |
@ -34,12 +34,12 @@ func (c *Category) Check() error {
|
|||||||
|
|
||||||
if c.Scheme != "" {
|
if c.Scheme != "" {
|
||||||
if !isValidURI(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) {
|
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 {
|
if c.Content == nil {
|
||||||
|
20
generator.go
20
generator.go
@ -1,6 +1,10 @@
|
|||||||
package atomfeed
|
package atomfeed
|
||||||
|
|
||||||
import "errors"
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"html"
|
||||||
|
)
|
||||||
|
|
||||||
type Generator struct {
|
type Generator struct {
|
||||||
*CommonAttributes
|
*CommonAttributes
|
||||||
@ -9,10 +13,24 @@ type Generator struct {
|
|||||||
Text string `xml:"text"`
|
Text string `xml:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewGenerator(text string) *Generator {
|
||||||
|
return &Generator{Text: html.UnescapeString(text)}
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Generator) Check() error {
|
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 == "" {
|
if g.Text == "" {
|
||||||
return errors.New("text element of generator empty")
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user