From e6fbc491a75602241c2f3e59481bbb6941f87e3f Mon Sep 17 00:00:00 2001 From: Jon de Andres Date: Thu, 29 Oct 2015 15:59:12 -0700 Subject: [PATCH] Fix URL scrubbing when using a malformed URL Fix #330 --- lib/rollbar/scrubbers/url.rb | 2 ++ spec/rollbar/scrubbers/url_spec.rb | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/rollbar/scrubbers/url.rb b/lib/rollbar/scrubbers/url.rb index 03027d8f..5336f541 100644 --- a/lib/rollbar/scrubbers/url.rb +++ b/lib/rollbar/scrubbers/url.rb @@ -28,6 +28,8 @@ def call(url) uri.query = filter_query(uri.query) uri.to_s + rescue + url end private diff --git a/spec/rollbar/scrubbers/url_spec.rb b/spec/rollbar/scrubbers/url_spec.rb index de20b5ae..2cbe1cd5 100644 --- a/spec/rollbar/scrubbers/url_spec.rb +++ b/spec/rollbar/scrubbers/url_spec.rb @@ -98,6 +98,14 @@ expect(subject.call(url)).to match(expected_url) end end + + context 'with malformed URL or not able to be parsed' do + let(:url) { '\this\is\not\a\valid\url' } + + it 'return the same url' do + expect(subject.call(url)).to be_eql(url) + end + end end end end