Fix Retention, ObjectLock, LegalHold struct namespaces correctly. (#8909)

Reverts #8903 to allow structs to be unmarshalled 
even if the namespace is missing.
This commit is contained in:
poornas
2020-01-29 20:28:05 -08:00
committed by GitHub
parent f6a7d4d29b
commit 881e983ed9
4 changed files with 24 additions and 8 deletions

View File

@@ -209,7 +209,8 @@ type topic struct {
// Config - notification configuration described in
// http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
type Config struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ NotificationConfiguration"`
XMLNS string `xml:"xmlns,attr,omitempty"`
XMLName xml.Name `xml:"NotificationConfiguration"`
QueueList []Queue `xml:"QueueConfiguration,omitempty"`
LambdaList []lambda `xml:"CloudFunctionConfiguration,omitempty"`
TopicList []topic `xml:"TopicConfiguration,omitempty"`
@@ -290,6 +291,9 @@ func ParseConfig(reader io.Reader, region string, targetList *TargetList) (*Conf
}
config.SetRegion(region)
//If xml namespace is empty, set a default value before returning.
if config.XMLNS == "" {
config.XMLNS = "http://s3.amazonaws.com/doc/2006-03-01/"
}
return &config, nil
}

View File

@@ -433,7 +433,7 @@ func TestConfigUnmarshalXML(t *testing.T) {
`)
dataCase3 := []byte(`
<NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<NotificationConfiguration>
<QueueConfiguration>
<Id>1</Id>
<Filter></Filter>