mattermost-community-enterp.../vendor/github.com/bep/imagemeta/metadecoder_xmp.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

71 lines
1.3 KiB
Go

// Copyright 2024 Bjørn Erik Pedersen
// SPDX-License-Identifier: MIT
package imagemeta
import (
"encoding/xml"
"errors"
"fmt"
"io"
)
var xmpSkipNamespaces = map[string]bool{
"xmlns": true,
"http://www.w3.org/1999/02/22-rdf-syntax-ns#": true,
"http://purl.org/dc/elements/1.1/": true,
}
type rdf struct {
Description rdfDescription `xml:"Description"`
}
type rdfDescription struct {
Attrs []xml.Attr `xml:",any,attr"`
}
type xmpmeta struct {
RDF rdf `xml:"RDF"`
}
func decodeXMP(r io.Reader, opts Options) error {
if opts.HandleXMP != nil {
if err := opts.HandleXMP(r); err != nil {
return err
}
// Read one more byte to make sure we're at EOF.
var b [1]byte
if _, err := r.Read(b[:]); err != io.EOF {
return errors.New("expected EOF after XMP")
}
return nil
}
var meta xmpmeta
if err := xml.NewDecoder(r).Decode(&meta); err != nil {
return newInvalidFormatError(fmt.Errorf("decoding XMP: %w", err))
}
for _, attr := range meta.RDF.Description.Attrs {
if xmpSkipNamespaces[attr.Name.Space] {
continue
}
tagInfo := TagInfo{
Source: XMP,
Tag: attr.Name.Local,
Namespace: attr.Name.Space,
Value: attr.Value,
}
if !opts.ShouldHandleTag(tagInfo) {
continue
}
if err := opts.HandleTag(tagInfo); err != nil {
return err
}
}
return nil
}