From dbd9d8d4c3c6a27ebf8add4fc20e790b94ca56a6 Mon Sep 17 00:00:00 2001 From: Dmitry Medvinsky Date: Fri, 22 Feb 2013 20:03:59 +0400 Subject: [PATCH] Fix WebHook and special symbols in credentials When using web hook with credentials secured web resource, one needs to put the credentials in the hook URL. If the credentials contain special symbols (e.g. @ or #), it should be URL-quoted (e.g. %40 instead of @). But when Gitlab is making a request, it should unquote the symbols before base64-encoding them. --- app/models/web_hook.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index efa27f31..3f22b108 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -28,10 +28,14 @@ class WebHook < ActiveRecord::Base WebHook.post(url, body: data.to_json, headers: { "Content-Type" => "application/json" }) else post_url = url.gsub("#{parsed_url.userinfo}@", "") + auth = { + username: URI.decode(parsed_url.user), + password: URI.decode(parsed_url.password), + } WebHook.post(post_url, body: data.to_json, headers: {"Content-Type" => "application/json"}, - basic_auth: {username: parsed_url.user, password: parsed_url.password}) + basic_auth: auth) end end