Unescape private_key loaded from ENV (#132)
This commit is contained in:
1 parent
18611aae6e
commit
9232aa3176
2 files changed
+17
-1
No files matched your search
@@ -58,7 +58,7 @@ module Google
|
||||
if json_key_io
|
||||
private_key, client_email = read_json_key(json_key_io)
|
||||
else
|
||||
private_key = ENV[CredentialsLoader::PRIVATE_KEY_VAR]
|
||||
private_key = unescape ENV[CredentialsLoader::PRIVATE_KEY_VAR]
|
||||
client_email = ENV[CredentialsLoader::CLIENT_EMAIL_VAR]
|
||||
end
|
||||
|
||||
@@ -78,6 +78,15 @@ module Google
|
||||
[json_key['private_key'], json_key['client_email']]
|
||||
end
|
||||
|
||||
# Handles certain escape sequences that sometimes appear in input.
|
||||
# Specifically, interprets the "\n" sequence for newline, and removes
|
||||
# enclosing quotes.
|
||||
def self.unescape(str)
|
||||
str = str.gsub '\n', "\n"
|
||||
str = str[1..-2] if str.start_with?('"') && str.end_with?('"')
|
||||
str
|
||||
end
|
||||
|
||||
def initialize(options = {})
|
||||
super(options)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user