Sha256: 35c80f497232ea8169a9a52f2938e40d5aa914b09ef4bfca12bd73a0e0b19cef

Contents?: true

Size: 553 Bytes

Versions: 5

Compression:

Stored size: 553 Bytes

Contents

# frozen_string_literal: true

require 'rbconfig'

class PDFKit
  module OS
    def self.host_is_windows?
      !(RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince/).nil?
    end

    def self.shell_escape_for_os(args)
      if (host_is_windows?)
        # Windows reserved shell characters are: & | ( ) < > ^
        # See http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection123121120120
        args.map { |arg| arg.gsub(/([&|()<>^])/,'^\1') }.join(" ")
      else
        args.shelljoin
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pdfkit-0.8.7.3 lib/pdfkit/os.rb
pdfkit-0.8.7.2 lib/pdfkit/os.rb
pdfkit-0.8.7.1 lib/pdfkit/os.rb
pdfkit-0.8.7 lib/pdfkit/os.rb
pdfkit-0.8.6 lib/pdfkit/os.rb