Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monkey yaml patching #137

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/whois_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class WhoisRecord < ActiveRecord::Base

def unix_body
file = File.new(template)
ERB.new(file.read, nil, "-").result(binding)
ERB.new(file.read, trim_mode: "-").result(binding)
end

def template
Expand Down
11 changes: 10 additions & 1 deletion lib/whois_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
load File.expand_path('../../app/models/whois_record.rb', __FILE__)
require_relative '../app/validators/unicode_validator'

module YAML
def self.properly_load_file(path)
YAML.load_file path, aliases: true
rescue ArgumentError
YAML.load_file path
end
end


module WhoisServer
def logger
@logger ||= Syslog::Logger.new 'whois'
Expand All @@ -14,7 +23,7 @@ def logger
def dbconfig
return @dbconfig unless @dbconfig.nil?
begin
dbconf = YAML.load(File.open(File.expand_path('../../config/database.yml', __FILE__)))
dbconf = YAML.properly_load_file(File.open(File.expand_path('../../config/database.yml', __FILE__)))
@dbconfig = dbconf[(ENV['WHOIS_ENV'] || 'development')]
rescue NoMethodError => e
logger.fatal "\n----> Please inspect config/database.yml for issues! Error: #{e}\n\n"
Expand Down