From 05f5c34fb0eed4bdda91e854ba00c5ab147d9724 Mon Sep 17 00:00:00 2001 From: Justin Schiff Date: Thu, 30 Jan 2025 15:13:46 -0800 Subject: [PATCH 1/3] Inserting into frozen string fails. Frozen strings cannot have `#insert` called on them, this was causing an error on the requests page. --- lib/mini_profiler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mini_profiler.rb b/lib/mini_profiler.rb index cccbce90..9b2107a5 100644 --- a/lib/mini_profiler.rb +++ b/lib/mini_profiler.rb @@ -470,7 +470,7 @@ def inject(fragment, script) safe_script = script.html_safe end - fragment.insert(index, safe_script) + fragment.dup.insert(index, safe_script) else fragment end From 279f0bbca5fc025163bd008169ef0ea92c968632 Mon Sep 17 00:00:00 2001 From: Nate Berkopec Date: Mon, 14 Apr 2025 08:20:31 +0900 Subject: [PATCH 2/3] Only dup blank page --- lib/mini_profiler.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mini_profiler.rb b/lib/mini_profiler.rb index 9b2107a5..edbe10ac 100644 --- a/lib/mini_profiler.rb +++ b/lib/mini_profiler.rb @@ -329,7 +329,7 @@ def call(env) ) end elsif path == '/rack-mini-profiler/requests' - status, headers, body = [200, { 'Content-Type' => 'text/html' }, [blank_page_html]] + status, headers, body = [200, { 'Content-Type' => 'text/html' }, [blank_page_html.dup]] # important to dup here! else status, headers, body = @app.call(env) end @@ -470,7 +470,7 @@ def inject(fragment, script) safe_script = script.html_safe end - fragment.dup.insert(index, safe_script) + fragment.insert(index, safe_script) else fragment end From 6e16e8cad6575daa745ce3b43d2cf58a12a91586 Mon Sep 17 00:00:00 2001 From: Nate Berkopec Date: Mon, 14 Apr 2025 08:28:26 +0900 Subject: [PATCH 3/3] Spec actually was incorrect: we werent inserting the script tag! --- spec/integration/middleware_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/integration/middleware_spec.rb b/spec/integration/middleware_spec.rb index acb6f98a..65ba066f 100644 --- a/spec/integration/middleware_spec.rb +++ b/spec/integration/middleware_spec.rb @@ -27,7 +27,7 @@ def app get '/rack-mini-profiler/requests', {}, 'HTTP_ACCEPT_ENCODING' => 'gzip, compress' expect(last_response.body).to include('Rack::MiniProfiler Requests') - expect(last_response.body).to match('\n ') + expect(last_response.body).to match('\n