Commit fefab474 authored by Dmitry Medvinsky's avatar Dmitry Medvinsky

Fix `/:username.keys` response content type

Currently this method responds with `text/html`. It is kind of unusable
if you open it in a browser. The browser thinks it is HTML and renders
it as HTML, meaning new lines are dropped. So it's very hard to
distinguish where the key starts and where it ends.

This commit changes the content type header to `text/plain`.
parent c0090a3f
...@@ -29,6 +29,7 @@ v 6.7.0 ...@@ -29,6 +29,7 @@ v 6.7.0
- Better API responses for access_levels (sponsored by O'Reilly Media) - Better API responses for access_levels (sponsored by O'Reilly Media)
- Requires at least 2 unicorn workers - Requires at least 2 unicorn workers
- Requires gitlab-shell v1.9+ - Requires gitlab-shell v1.9+
- Fix `/:username.keys` response content type (Dmitry Medvinsky)
v 6.6.5 v 6.6.5
- Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard)
......
...@@ -41,7 +41,7 @@ class Profiles::KeysController < ApplicationController ...@@ -41,7 +41,7 @@ class Profiles::KeysController < ApplicationController
begin begin
user = User.find_by_username(params[:username]) user = User.find_by_username(params[:username])
if user.present? if user.present?
render text: user.all_ssh_keys.join("\n") render text: user.all_ssh_keys.join("\n"), content_type: "text/plain"
else else
render_404 and return render_404 and return
end end
......
...@@ -24,6 +24,11 @@ describe Profiles::KeysController do ...@@ -24,6 +24,11 @@ describe Profiles::KeysController do
expect(response.body).to eq("") expect(response.body).to eq("")
end end
it "should respond with text/plain content type" do
get :get_keys, username: user.username
expect(response.content_type).to eq("text/plain")
end
end end
describe "user with keys" do describe "user with keys" do
...@@ -44,6 +49,11 @@ describe Profiles::KeysController do ...@@ -44,6 +49,11 @@ describe Profiles::KeysController do
expect(response.body).not_to eq("") expect(response.body).not_to eq("")
expect(response.body).to eq(user.all_ssh_keys.join("\n")) expect(response.body).to eq(user.all_ssh_keys.join("\n"))
end end
it "should respond with text/plain content type" do
get :get_keys, username: user.username
expect(response.content_type).to eq("text/plain")
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment