mirror of https://github.com/minio/minio.git
				
				
				
			Fix S3 Select request XML parsing (#7202)
This commit is contained in:
		
							parent
							
								
									5fb813a5cc
								
							
						
					
					
						commit
						4aa9ee153b
					
				| 
						 | 
					@ -65,6 +65,8 @@ func (args *ReaderArgs) UnmarshalXML(d *xml.Decoder, start xml.StartElement) err
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	parsedArgs.FileHeaderInfo = strings.ToLower(parsedArgs.FileHeaderInfo)
 | 
						parsedArgs.FileHeaderInfo = strings.ToLower(parsedArgs.FileHeaderInfo)
 | 
				
			||||||
	switch parsedArgs.FileHeaderInfo {
 | 
						switch parsedArgs.FileHeaderInfo {
 | 
				
			||||||
 | 
						case "":
 | 
				
			||||||
 | 
							parsedArgs.FileHeaderInfo = none
 | 
				
			||||||
	case none, use, ignore:
 | 
						case none, use, ignore:
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return errInvalidFileHeaderInfo(fmt.Errorf("invalid FileHeaderInfo '%v'", parsedArgs.FileHeaderInfo))
 | 
							return errInvalidFileHeaderInfo(fmt.Errorf("invalid FileHeaderInfo '%v'", parsedArgs.FileHeaderInfo))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,6 +99,11 @@ func (input *InputSerialization) UnmarshalXML(d *xml.Decoder, start xml.StartEle
 | 
				
			||||||
		return errMalformedXML(err)
 | 
							return errMalformedXML(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// If no compression is specified, set to noneType
 | 
				
			||||||
 | 
						if parsedInput.CompressionType == CompressionType("") {
 | 
				
			||||||
 | 
							parsedInput.CompressionType = noneType
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	found := 0
 | 
						found := 0
 | 
				
			||||||
	if !parsedInput.CSVArgs.IsEmpty() {
 | 
						if !parsedInput.CSVArgs.IsEmpty() {
 | 
				
			||||||
		parsedInput.format = csvFormat
 | 
							parsedInput.format = csvFormat
 | 
				
			||||||
| 
						 | 
					@ -172,10 +177,10 @@ type RequestProgress struct {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// S3Select - filters the contents on a simple structured query language (SQL) statement. It
 | 
					// S3Select - filters the contents on a simple structured query language (SQL) statement. It
 | 
				
			||||||
// represents elements inside <SelectObjectContentRequest/> in request XML specified in detail at
 | 
					// represents elements inside <SelectRequest/> in request XML specified in detail at
 | 
				
			||||||
// https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectSELECTContent.html.
 | 
					// https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectSELECTContent.html.
 | 
				
			||||||
type S3Select struct {
 | 
					type S3Select struct {
 | 
				
			||||||
	XMLName        xml.Name            `xml:"SelectObjectContentRequest"`
 | 
						XMLName        xml.Name            `xml:"SelectRequest"`
 | 
				
			||||||
	Expression     string              `xml:"Expression"`
 | 
						Expression     string              `xml:"Expression"`
 | 
				
			||||||
	ExpressionType string              `xml:"ExpressionType"`
 | 
						ExpressionType string              `xml:"ExpressionType"`
 | 
				
			||||||
	Input          InputSerialization  `xml:"InputSerialization"`
 | 
						Input          InputSerialization  `xml:"InputSerialization"`
 | 
				
			||||||
| 
						 | 
					@ -187,8 +192,20 @@ type S3Select struct {
 | 
				
			||||||
	recordReader   recordReader
 | 
						recordReader   recordReader
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var (
 | 
				
			||||||
 | 
						legacyXMLName = "SelectObjectContentRequest"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UnmarshalXML - decodes XML data.
 | 
					// UnmarshalXML - decodes XML data.
 | 
				
			||||||
func (s3Select *S3Select) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
 | 
					func (s3Select *S3Select) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
 | 
				
			||||||
 | 
						// S3 also supports the older SelectObjectContentRequest tag,
 | 
				
			||||||
 | 
						// though it is no longer found in documentation. This is
 | 
				
			||||||
 | 
						// checked and renamed below to allow older clients to also
 | 
				
			||||||
 | 
						// work.
 | 
				
			||||||
 | 
						if start.Name.Local == legacyXMLName {
 | 
				
			||||||
 | 
							start.Name = xml.Name{Space: "", Local: "SelectRequest"}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Make subtype to avoid recursive UnmarshalXML().
 | 
						// Make subtype to avoid recursive UnmarshalXML().
 | 
				
			||||||
	type subS3Select S3Select
 | 
						type subS3Select S3Select
 | 
				
			||||||
	parsedS3Select := subS3Select{}
 | 
						parsedS3Select := subS3Select{}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue