Compare commits
No commits in common. "e73b78ef3080edbab31c8c2a46c585684ab88e52" and "73624eadd8777db7053b94f19c921f58e7d7ae7a" have entirely different histories.
e73b78ef30
...
73624eadd8
7
atom.go
7
atom.go
@ -1,7 +1,6 @@
|
||||
package atom
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"mime"
|
||||
"regexp"
|
||||
@ -87,9 +86,3 @@ func isValidLanguageTag(tag LanguageTag) bool {
|
||||
func NewURN() IRI {
|
||||
return IRI(fmt.Sprint("urn:uuid:", uuid.New()))
|
||||
}
|
||||
|
||||
// isValidXML checks whether a string is valid XML. It returns a bool.
|
||||
func isValidXML(input string) bool {
|
||||
var v interface{}
|
||||
return xml.Unmarshal([]byte(input), &v) == nil
|
||||
}
|
||||
|
12
category.go
12
category.go
@ -16,12 +16,6 @@ type Category struct {
|
||||
|
||||
// NewCategory creates a new Category. It returns a *Category and an error.
|
||||
func NewCategory(term, content string) (*Category, error) {
|
||||
if content != "" {
|
||||
if !isValidXML(content) {
|
||||
return nil, fmt.Errorf("%v not valid XML", content)
|
||||
}
|
||||
}
|
||||
|
||||
return &Category{Term: term, Content: content}, nil
|
||||
}
|
||||
|
||||
@ -47,10 +41,8 @@ func (c *Category) Check() error {
|
||||
return fmt.Errorf("label attribute %v of category not correctly escaped", c.Label)
|
||||
}
|
||||
|
||||
if c.Content != "" {
|
||||
if !isValidXML(c.Content) {
|
||||
return fmt.Errorf("content element %v of category not valid XML", c.Content)
|
||||
}
|
||||
if c.Content == "" {
|
||||
return errors.New("content element of category empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
12
link.go
12
link.go
@ -19,12 +19,6 @@ type Link struct {
|
||||
|
||||
// NewLink creates a new Link. It returns a *Link and an error.
|
||||
func NewLink(href, content string) (*Link, error) {
|
||||
if content != "" {
|
||||
if !isValidXML(content) {
|
||||
return nil, fmt.Errorf("%v not valid XML", content)
|
||||
}
|
||||
}
|
||||
|
||||
return &Link{Href: IRI(href), Content: content}, nil
|
||||
}
|
||||
|
||||
@ -57,10 +51,8 @@ func (l *Link) Check() error {
|
||||
}
|
||||
}
|
||||
|
||||
if l.Content != "" {
|
||||
if !isValidXML(l.Content) {
|
||||
return fmt.Errorf("content element %v of link not valid XML", l.Content)
|
||||
}
|
||||
if l.Content == "" {
|
||||
return errors.New("content element of link empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user