Check if the type of contents is a composite media type

This commit is contained in:
Jason Streifling 2024-10-15 19:53:17 +02:00
parent 6322566a54
commit 987feb8226
2 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,7 @@
package atomfeed
import "errors"
type InlineOtherContent struct {
*CommonAttributes
Type MediaType `xml:"type,attr,omitempty"`
@ -12,4 +14,10 @@ func (i *InlineOtherContent) hasSRC() bool { return false }
func (i *InlineOtherContent) getType() string { return string(i.Type) }
func (i *InlineOtherContent) Check() error { return nil }
func (i *InlineOtherContent) Check() error {
if isCompositeMediaType(i.getType()) {
return errors.New("type attribute of inline other content must not be a composite type")
}
return nil
}

View File

@ -15,6 +15,10 @@ func (o *OutOfLineContent) hasSRC() bool { return true }
func (o *OutOfLineContent) getType() string { return string(o.Type) }
func (o *OutOfLineContent) Check() error {
if isCompositeMediaType(o.getType()) {
return errors.New("type attribute of out of line content must not be a composite type")
}
if o.SRC == "" {
return errors.New("src attribute of out of line content empty")
}