From 987feb822615886361262a7bb1bf811a1f821470 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 15 Oct 2024 19:53:17 +0200 Subject: [PATCH] Check if the type of contents is a composite media type --- inlineOtherContent.go | 10 +++++++++- outOfLineContent.go | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/inlineOtherContent.go b/inlineOtherContent.go index dec8bd2..d55bc8d 100644 --- a/inlineOtherContent.go +++ b/inlineOtherContent.go @@ -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 +} diff --git a/outOfLineContent.go b/outOfLineContent.go index e3805e9..17d4f64 100644 --- a/outOfLineContent.go +++ b/outOfLineContent.go @@ -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") }