Force undefined content of category and link to be empty or valid xml

This commit is contained in:
2024-10-17 18:39:57 +02:00
parent 73624eadd8
commit 5a82f1799f
3 changed files with 23 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package atom
import (
"encoding/xml"
"fmt"
"mime"
"regexp"
@@ -86,3 +87,9 @@ 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
}