Skip to content

Commit

Permalink
Fix listobjects with metadata
Browse files Browse the repository at this point in the history
`UserMetadata` did not match actual format sent.
Change type of `UserTags`, so it can be unmarshaled from XML.

Fix for minio server that matches this will be sent.

Tested with mc.
  • Loading branch information
klauspost committed Mar 30, 2023
1 parent 6fcbe6d commit 83c0754
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions api-datatypes.go
Expand Up @@ -43,14 +43,29 @@ type StringMap map[string]string
// if m is nil it can be initialized, which is often the case if m is
// nested in another xml structural. This is also why the first thing done
// on the first line is initialize it.
func (m *StringMap) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error {
func (m *StringMap) UnmarshalXML(d *xml.Decoder, s xml.StartElement) error {
*m = StringMap{}
type Item struct {
Key string
Value string
}
for {
var e Item
// Fallback for <key>value</key>
if s.Name.Local == "UserMetadata" {
var e struct {
XMLName xml.Name
Value string `xml:",chardata"`
}
err := d.Decode(&e)
if err == io.EOF {
break
}
if err != nil {
return err
}
(*m)[e.XMLName.Local] = e.Value
continue
}
var e struct {
Key string
Value string
}
err := d.Decode(&e)
if err == io.EOF {
break
Expand Down Expand Up @@ -124,7 +139,7 @@ type ObjectInfo struct {
UserMetadata StringMap `json:"userMetadata,omitempty"`

// x-amz-tagging values in their k/v values.
UserTags map[string]string `json:"userTags"`
UserTags StringMap `json:"userTags" xml:"TagSet"`

// x-amz-tagging-count value
UserTagCount int
Expand Down

0 comments on commit 83c0754

Please sign in to comment.