@@ -569,7 +569,9 @@ static struct aws_string *s_etag_new_from_upload_part_copy_response(
569569 const char * xml_path [] = {"CopyPartResult" , "ETag" , NULL };
570570 aws_xml_get_body_at_path (allocator , xml_doc , xml_path , & etag_within_xml_quotes );
571571
572- struct aws_byte_buf etag_within_quotes_byte_buf = aws_replace_quote_entities (allocator , etag_within_xml_quotes );
572+ struct aws_byte_buf etag_within_quotes_byte_buf ;
573+ aws_byte_buf_init (& etag_within_quotes_byte_buf , allocator , 20 );
574+ aws_byte_buf_append_unescaped_xml (allocator , etag_within_xml_quotes , & etag_within_quotes_byte_buf );
573575
574576 struct aws_string * stripped_etag =
575577 aws_strip_quotes (allocator , aws_byte_cursor_from_buf (& etag_within_quotes_byte_buf ));
@@ -770,13 +772,20 @@ static void s_s3_copy_object_request_finished(
770772 const char * xml_path [] = {"CompleteMultipartUploadResult" , "ETag" , NULL };
771773 aws_xml_get_body_at_path (meta_request -> allocator , xml_doc , xml_path , & etag_header_value );
772774 if (etag_header_value .len > 0 ) {
773- struct aws_byte_buf etag_header_value_byte_buf =
774- aws_replace_quote_entities (meta_request -> allocator , etag_header_value );
775-
776- aws_http_headers_set (
777- request -> send_data .response_headers ,
778- g_etag_header_name ,
779- aws_byte_cursor_from_buf (& etag_header_value_byte_buf ));
775+ struct aws_byte_buf etag_header_value_byte_buf ;
776+ aws_byte_buf_init (& etag_header_value_byte_buf , meta_request -> allocator , 20 );
777+ if (aws_byte_buf_append_unescaped_xml (
778+ meta_request -> allocator , etag_header_value , & etag_header_value_byte_buf )) {
779+ AWS_LOGF_ERROR (
780+ AWS_LS_S3_META_REQUEST , "Server returned unexpected etag format. skipping etag unescaping" );
781+ aws_http_headers_set (
782+ request -> send_data .response_headers , g_etag_header_name , etag_header_value );
783+ } else {
784+ aws_http_headers_set (
785+ request -> send_data .response_headers ,
786+ g_etag_header_name ,
787+ aws_byte_cursor_from_buf (& etag_header_value_byte_buf ));
788+ }
780789
781790 aws_byte_buf_clean_up (& etag_header_value_byte_buf );
782791 }
0 commit comments