Skip to content

Commit

Permalink
Tighten regex used for S3 200 errors (#3130)
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp authored Nov 11, 2024
1 parent c591160 commit 8a667ab
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 142 deletions.
2 changes: 2 additions & 0 deletions gems/aws-sdk-s3/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Tighten regex used to check for S3 200 errors.

1.170.0 (2024-11-06)
------------------

Expand Down
6 changes: 3 additions & 3 deletions gems/aws-sdk-s3/lib/aws-sdk-s3/plugins/http_200_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def incomplete_xml_body?(xml, output)

def check_for_error(context)
xml = context.http_response.body_contents
if xml.match(/\?>\s*<Error>/)
error_code = xml.match(/<Code>(.+?)<\/Code>/)[1]
error_message = xml.match(/<Message>(.+?)<\/Message>/)[1]
if xml.match(/<\?xml\s[^>]*\?>\s*<Error>/)
error_code = xml.match(%r{<Code>(.+?)</Code>})[1]
error_message = xml.match(%r{<Message>(.+?)</Message>})[1]
S3::Errors.error_class(error_code).new(context, error_message)
elsif incomplete_xml_body?(xml, context.operation.output)
Seahorse::Client::NetworkingError.new(
Expand Down
Loading

0 comments on commit 8a667ab

Please sign in to comment.