lib/pdfkit/source.rb in pdfkit-0.8.5 vs lib/pdfkit/source.rb in pdfkit-0.8.6

- old
+ new

@@ -1,14 +1,18 @@ +# frozen_string_literal: true + require 'tempfile' require 'uri' class PDFKit class Source SOURCE_FROM_STDIN = '-' def initialize(url_file_or_html) @source = url_file_or_html + # @source is assumed to be modifiable, so make sure it is. + @source = @source.dup if @source.is_a?(String) && @source.frozen? end def url? @is_url ||= @source.is_a?(String) && @source.match(/\Ahttp/) end @@ -36,13 +40,13 @@ end private def shell_safe_url - url_needs_escaping? ? URI::escape(@source) : @source + url_needs_escaping? ? URI::DEFAULT_PARSER.escape(@source) : @source end def url_needs_escaping? - URI::decode(@source) == @source + URI::DEFAULT_PARSER.unescape(@source) == @source end end end