Skip to content

Commit 093a47b

Browse files
committed
handle encoding after nil check
1 parent c808576 commit 093a47b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/jekyll-gist/gist_tag.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def gist_script_tag(gist_id, filename = nil)
5252
def gist_noscript_tag(gist_id, filename = nil)
5353
code = fetch_raw_code(gist_id, filename)
5454
if !code.nil?
55+
code = code.force_encoding(@encoding)
5556
"<noscript><pre>#{CGI.escapeHTML(code)}</pre></noscript>"
5657
else
5758
Jekyll.logger.warn "Warning:", "The <noscript> tag for your gist #{gist_id} could not"
@@ -70,7 +71,7 @@ def fetch_raw_code(gist_id, filename = nil)
7071
read_timeout: 3, open_timeout: 3) do |http|
7172
request = Net::HTTP::Get.new uri.to_s
7273
response = http.request(request)
73-
response.body.force_encoding(@encoding)
74+
response.body
7475
end
7576
rescue SocketError, Net::HTTPError, Net::OpenTimeout, Net::ReadTimeout, TimeoutError
7677
nil

0 commit comments

Comments
 (0)