fastlane/lib/fastlane/actions/hipchat.rb in fastlane-2.55.0.beta.20170830010003 vs fastlane/lib/fastlane/actions/hipchat.rb in fastlane-2.55.0.beta.20170831010002
- old
+ new
@@ -44,22 +44,25 @@
check_response_code(response, channel)
end
else
########## running on V2 ##########
+ # Escape channel's name to guarantee it is a valid URL resource.
+ # First of all we verify that the value is not already escaped,
+ # escaping an escaped value will produce a wrong channel name.
+ escaped_channel = URI.unescape(channel) == channel ? URI.escape(channel) : channel
if user?(channel)
params = { 'message' => message, 'message_format' => message_format }
json_headers = { 'Content-Type' => 'application/json',
'Accept' => 'application/json', 'Authorization' => "Bearer #{api_token}" }
- escaped_channel = URI.unescape(channel) == channel ? URI.escape(channel) : channel
uri = URI.parse("https://#{api_host}/v2/user/#{escaped_channel}/message")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
response = http.post(uri.path, params.to_json, json_headers)
else
- uri = URI.parse("https://#{api_host}/v2/room/#{channel}/notification")
+ uri = URI.parse("https://#{api_host}/v2/room/#{escaped_channel}/notification")
response = Net::HTTP.post_form(uri, { 'from' => from,
'auth_token' => api_token,
'color' => color,
'message_format' => message_format,
'message' => message,