From 854aaec6fe69df02e6d850cb90eef37032b4d72f Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 19 Sep 2025 11:22:23 -0400 Subject: [PATCH] Spec for newline in request lib initialize (#36170) --- spec/lib/request_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/lib/request_spec.rb b/spec/lib/request_spec.rb index 79c400e098e..da618234550 100644 --- a/spec/lib/request_spec.rb +++ b/spec/lib/request_spec.rb @@ -40,6 +40,23 @@ RSpec.describe Request do end end + describe '#initialize' do + subject { described_class.new(:get, url) } + + context 'when URL has new lines' do + let(:url) { "https://host.example/image\nhttps://badhost.example/page.jpg" } + + it 'encodes new lines in url value after normalization' do + expect(initialized_url_value) + .to eq('https://host.example/image%0Ahttps://badhost.example/page.jpg') + end + end + + def initialized_url_value + subject.instance_variable_get(:@url).to_s + end + end + describe '#perform' do context 'with valid host and non-persistent connection' do before { stub_request(:get, 'http://example.com').to_return(body: 'lorem ipsum') }