|
8 | 8 | #include "aws/s3/private/s3_request_messages.h" |
9 | 9 | #include "aws/s3/private/s3_util.h" |
10 | 10 | #include <aws/common/string.h> |
| 11 | +#include <aws/common/xml_parser.h> |
11 | 12 |
|
12 | 13 | /* Objects with size smaller than the constant below are bypassed as S3 CopyObject instead of multipart copy */ |
13 | 14 | static const size_t s_multipart_copy_minimum_object_size = GB_TO_BYTES(1); |
@@ -569,7 +570,9 @@ static struct aws_string *s_etag_new_from_upload_part_copy_response( |
569 | 570 | const char *xml_path[] = {"CopyPartResult", "ETag", NULL}; |
570 | 571 | aws_xml_get_body_at_path(allocator, xml_doc, xml_path, &etag_within_xml_quotes); |
571 | 572 |
|
572 | | - struct aws_byte_buf etag_within_quotes_byte_buf = aws_replace_quote_entities(allocator, etag_within_xml_quotes); |
| 573 | + struct aws_byte_buf etag_within_quotes_byte_buf; |
| 574 | + aws_byte_buf_init(&etag_within_quotes_byte_buf, allocator, 20); |
| 575 | + aws_byte_buf_append_unescaped_xml(allocator, etag_within_xml_quotes, &etag_within_quotes_byte_buf); |
573 | 576 |
|
574 | 577 | struct aws_string *stripped_etag = |
575 | 578 | aws_strip_quotes(allocator, aws_byte_cursor_from_buf(&etag_within_quotes_byte_buf)); |
@@ -770,13 +773,20 @@ static void s_s3_copy_object_request_finished( |
770 | 773 | const char *xml_path[] = {"CompleteMultipartUploadResult", "ETag", NULL}; |
771 | 774 | aws_xml_get_body_at_path(meta_request->allocator, xml_doc, xml_path, &etag_header_value); |
772 | 775 | 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)); |
| 776 | + struct aws_byte_buf etag_header_value_byte_buf; |
| 777 | + aws_byte_buf_init(&etag_header_value_byte_buf, meta_request->allocator, 20); |
| 778 | + if (aws_byte_buf_append_unescaped_xml( |
| 779 | + meta_request->allocator, etag_header_value, &etag_header_value_byte_buf)) { |
| 780 | + AWS_LOGF_ERROR( |
| 781 | + AWS_LS_S3_META_REQUEST, "Server returned unexpected etag format. skipping etag unescaping"); |
| 782 | + aws_http_headers_set( |
| 783 | + request->send_data.response_headers, g_etag_header_name, etag_header_value); |
| 784 | + } else { |
| 785 | + aws_http_headers_set( |
| 786 | + request->send_data.response_headers, |
| 787 | + g_etag_header_name, |
| 788 | + aws_byte_cursor_from_buf(&etag_header_value_byte_buf)); |
| 789 | + } |
780 | 790 |
|
781 | 791 | aws_byte_buf_clean_up(&etag_header_value_byte_buf); |
782 | 792 | } |
|
0 commit comments