From 727d9110f47ea0a534a90b468ad7e4d4b7975ef7 Mon Sep 17 00:00:00 2001 From: Johan Carlquist Date: Sun, 31 Aug 2014 14:24:19 +0200 Subject: [PATCH] Chomp OAuth access token before use. If a user is modifying the .gist file by hand there is a big risk that the user adds a newline to the file. That newline is causing gist to fail with "Error: Got Net::HTTPUnauthorized from gist:". So better remove the eventual newline with chomp before use. This is extra handy when setting up gist on an computer that you don't trust with your real GitHub credentials (pre-generated OAuth token). --- lib/gist.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gist.rb b/lib/gist.rb index ac27ec8..bc30d06 100644 --- a/lib/gist.rb +++ b/lib/gist.rb @@ -44,7 +44,7 @@ class ClipboardError < RuntimeError; include Error end # # @return [String] string value of access token or `nil`, if not found def auth_token - @token ||= File.read(auth_token_file) rescue nil + @token ||= File.read(auth_token_file).chomp rescue nil end # Upload a gist to https://gist.github.com