Skip to content

Commit

Permalink
Handling of BOM files with search pattern for specific bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
canimus committed Feb 17, 2013
1 parent a592617 commit 6445cec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/parseconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialize(config_file=nil)

# Validate the config file, and contents
def validate_config()
if !File.readable?(self.config_file)
unless File.readable?(self.config_file)
raise Errno::EACCES, "#{self.config_file} is not readable"
end

Expand All @@ -53,8 +53,13 @@ def import_config()
# The config is top down.. anything after a [group] gets added as part
# of that group until a new [group] is found.
group = nil
open(self.config_file) { |f| f.each do |line|
open(self.config_file) { |f| f.each_with_index do |line, i|
line.strip!

if i.eql? 0 and line.include?("\xef\xbb\xbf".force_encoding("UTF-8"))
line.delete!("\xef\xbb\xbf".force_encoding("UTF-8"))
end

unless (/^\#/.match(line))
if(/\s*=\s*/.match(line))
param, value = line.split(/\s*=\s*/, 2)
Expand Down

0 comments on commit 6445cec

Please sign in to comment.