def validate_config
      message = 'bad path in config'

      # Checks the option in the asset key.
      def validate_asset_options(opts)
        opts.each do |k, v|
          fail 'bad option in config' if k == :sprockets_options
          fail message if k == :output && !Utils.safe_path?(v)
        end
      end

      @config[:excludes].each do |v|
        fail message unless Utils.safe_path? v
      end unless @config[:excludes].nil?

      @config[:external].each do |k, v|
        next if k == :server

        v.each do |repo|
          fail message unless Utils.safe_path? repo[1]
        end unless v.nil?
      end unless @config[:external].nil?

      @config[:components].each do |k, v|
        # process @config[:components][:base] then go to the next option
        if k == :base
          fail message unless Utils.safe_path? v
          next
        end unless v.nil?

        # process @config[:components][:paths]
        if k == :paths
          v.each do |path|
            fail message unless Utils.safe_path? path[0]
            fail message unless Utils.safe_path? path[1]
          end
        end
      end unless @config[:components].nil?

      @config[:assets].each do |k, v|
        # process @config[:assets][:options] then go to the next option
        if k == :options
          validate_asset_options v
          next
        end unless v.nil?

        # process @config[:assets][:sources] then go to the next option
        if k == :sources
          v.each_with_index do |source, _|
            fail message unless Utils.safe_path? source
          end
          next
        end

        # process each asset type in @config[:assets]
        v.each do |asset_key, asset_value|
          # process :options
          if asset_key == :options
            validate_asset_options asset_value
            next
          end unless asset_value.nil?

          # process each asset path
          asset_value.each_with_index do |path, _|
            fail message unless Utils.safe_path? path
          end if asset_key == :paths
        end
      end unless @config[:assets].nil?

      @config
    end
def validate_config
      message = 'bad path in config'

      # Checks the option in the asset key.
      def validate_asset_options(opts)
        opts.each do |k, v|
          fail 'bad option in config' if k == :sprockets_options
          fail message if k == :output && !Utils.safe_path?(v)
        end
      end

      @config[:excludes].each do |v|
        fail message unless Utils.safe_path? v
      end unless @config[:excludes].nil?

      @config[:external].each do |k, v|
        next if k == :server

        v.each do |repo|
          fail message unless Utils.safe_path? repo[1]
        end unless v.nil?
      end unless @config[:external].nil?

      @config[:components].each do |k, v|
        # process @config[:components][:base] then go to the next option
        if k == :base
          fail message unless Utils.safe_path? v
          next
        end unless v.nil?

        # process @config[:components][:paths]
        if k == :paths
          v.each do |path|
            fail message unless Utils.safe_path? path[0]
            fail message unless Utils.safe_path? path[1]
          end
        end
      end unless @config[:components].nil?

      @config[:assets].each do |k, v|
        # process @config[:assets][:options] then go to the next option
        if k == :options
          validate_asset_options v
          next
        end unless v.nil?

        # process @config[:assets][:sources] then go to the next option
        if k == :sources
          v.each_with_index do |source, _|
            fail message unless Utils.safe_path? source
          end
          next
        end

        # process each asset type in @config[:assets]
        v.each do |asset_key, asset_value|
          # process :options
          if asset_key == :options
            validate_asset_options asset_value
            next
          end unless asset_value.nil?

          # process each asset path
          asset_value.each_with_index do |path, _|
            fail message unless Utils.safe_path? path
          end if asset_key == :paths
        end
      end unless @config[:assets].nil?

      @config
    end
Checks the config file for invalid settings.
 @todo Refactor this.
 - Checks that paths are not absolute or use `../` or `~/`.