Skip to content

Commit

Permalink
Merge pull request #1066 from c960657/invalid-xml
Browse files Browse the repository at this point in the history
Ignore parse exceptions
  • Loading branch information
bblimke authored Sep 18, 2024
2 parents a7bb2fc + 69c45b8 commit 4a8a513
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/webmock/request_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def body_as_hash(body, content_type)
else
WebMock::Util::QueryMapper.query_to_values(body, notation: Config.instance.query_values_notation)
end
rescue Psych::SyntaxError, REXML::ParseException
end

def body_format(content_type)
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/request_pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def match(request_signature)
it "should not match when body is not json" do
expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
headers: {content_type: content_type}, body: "foo bar"))
headers: {content_type: content_type}, body: "[foo bar"))
end

it "should not match if request body is different" do
Expand Down Expand Up @@ -614,7 +614,7 @@ def match(request_signature)
it "should not match when body is not xml" do
expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
headers: {content_type: content_type}, body: "foo bar"))
headers: {content_type: content_type}, body: "<foo bar"))
end

it "matches when the content type include a charset" do
Expand Down

0 comments on commit 4a8a513

Please sign in to comment.