Commit 4ef12ecf authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Only apply the UTF-8 BOM stripping in Ruby 1.8.

Something goes wrong when we execute this BOM-stripping code in
Ruby 1.8 which has encodings support.  Didn't care to digg into this,
and so I'm just limiting this fix to Ruby 1.8 where it's actually
needed.
parent 1afeace1
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -28,11 +28,15 @@ module JsDuck
        File.open(filename, "r:"+@@encoding) {|f| self.strip_utf8_bom(f.read) }
      end

      # Takes care of removing UTF-8 byte order mark in Ruby 1.8 which
      # Takes care of removing UTF-8 byte order mark in Ruby <= 1.8 which
      # doesn't have built-in encodings support.
      def self.strip_utf8_bom(string)
        if "".respond_to?(:encoding)
          string
        else
          string.sub(/\A\xEF\xBB\xBF/, "")
        end
      end

    end