pdfkit 0.8.4.2 → 0.8.4.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pdfkit might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d07f9293cf2555d6bf3f44fce50ff185524fd202073fcd00fe0e6b2fb094963d
4
- data.tar.gz: ede68296b5314d8572b002945360e0c2cb90d95f57440f8a6213d9054a436dcc
3
+ metadata.gz: 1abe171f52890a9f122ae67cfc5c743ac486414bf6ffe78a72d767fccb7b43a6
4
+ data.tar.gz: c979fcb4caa6d667be6b2f636e1acff3e4edaa59bf9e5ce45a709225fd4a3491
5
5
  SHA512:
6
- metadata.gz: 2447695954315c580730d87c1f0ed2353228ca3e564a5692fef67d4d2d2fc244e6f2442e1b69c433f35b92c685acc35cd3764c111dcaa69f773cd67e77d725e7
7
- data.tar.gz: b106bb8ead667a62cca3f4790ea0c074301ea02ab693e7b39a5b7006ddc314700a95eed42507c007010c8134c40665024d32a421e664541aff8a0d6bd9ddd4db
6
+ metadata.gz: 70ac2e72c5aab61b4cfffe9bd26da109dee62286f8486d3596522dff5c0eb9b9ae5c1886b53d2b979247b2b6f38d9e8de07344d4963b8f1109879fd077550d0a
7
+ data.tar.gz: 28c303321d80381c13e3071442cfd9652469e8c15cd977224762ddb93342ec3f5bed8be6e9b014f771490f38f365b7d3b21d771ead7931b751b7eee1cebf962f
@@ -12,5 +12,5 @@ before_install:
12
12
 
13
13
  before_script:
14
14
  - "sudo apt-get -qq -y install fontconfig libxrender1"
15
- - "wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.xenial_amd64.deb"
15
+ - "wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.xenial_amd64.deb"
16
16
  - "sudo apt-get install ./wkhtmltox_0.12.5-1.xenial_amd64.deb"
@@ -1,3 +1,13 @@
1
+ 2020-07-05
2
+ =================
3
+ * Bump to 0.8.4.3.1
4
+ * Don't override request level Content-Disposition header if it exists (#466)
5
+ * Update rake (#471)
6
+ * Add missing require statements for tempfile (#467)
7
+ * Only grab last line of bundle exec which output (#464)
8
+ * Return 500 status when an exception is caught in middleware (#469)
9
+ * Update Travis CI URL for wkhtmltopf (#473)
10
+
1
11
  2020-04-01
2
12
  =================
3
13
  * Bump to 0.8.4.2
data/README.md CHANGED
@@ -119,9 +119,9 @@ config.middleware.use PDFKit::Middleware, {}, :except => ['/secret']
119
119
  **With conditions to force download**
120
120
  ```ruby
121
121
  # force download with attachment disposition
122
- config.middleware.use PDFKit::Middleware, {}, :dispositon => 'attachment'
122
+ config.middleware.use PDFKit::Middleware, {}, :disposition => 'attachment'
123
123
  # conditions can force a filename
124
- config.middleware.use PDFKit::Middleware, {}, :dispositon => 'attachment; filename=report.pdf'
124
+ config.middleware.use PDFKit::Middleware, {}, :disposition => 'attachment; filename=report.pdf'
125
125
  ```
126
126
  **Saving the generated .pdf to disk**
127
127
 
@@ -27,7 +27,7 @@ class PDFKit
27
27
  def default_wkhtmltopdf
28
28
  return @default_command_path if @default_command_path
29
29
  if defined?(Bundler::GemfileError) && File.exists?('Gemfile')
30
- @default_command_path = `bundle exec which wkhtmltopdf`.chomp
30
+ @default_command_path = `bundle exec which wkhtmltopdf`.chomp.lines.last
31
31
  end
32
32
  @default_command_path = `which wkhtmltopdf`.chomp if @default_command_path.nil? || @default_command_path.empty?
33
33
  @default_command_path
@@ -47,9 +47,15 @@ class PDFKit
47
47
 
48
48
  headers['Content-Length'] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
49
49
  headers['Content-Type'] = 'application/pdf'
50
- headers['Content-Disposition'] = @conditions[:disposition] || 'inline'
50
+ headers['Content-Disposition'] ||= @conditions[:disposition] || 'inline'
51
51
  end
52
52
 
53
+ [status, headers, response]
54
+
55
+ rescue StandardError => e
56
+ status = 500
57
+ response = [e.message]
58
+
53
59
  [status, headers, response]
54
60
  end
55
61
 
@@ -1,4 +1,5 @@
1
1
  require 'shellwords'
2
+ require 'tempfile'
2
3
 
3
4
  class PDFKit
4
5
  class Error < StandardError; end
@@ -1,3 +1,4 @@
1
+ require 'tempfile'
1
2
  require 'uri'
2
3
 
3
4
  class PDFKit
@@ -1,3 +1,3 @@
1
1
  class PDFKit
2
- VERSION = '0.8.4.2'
2
+ VERSION = '0.8.4.3.1'
3
3
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency(%q<activesupport>, [">= 4.1.11"])
25
25
  s.add_development_dependency(%q<mocha>, [">= 0.9.10"])
26
26
  s.add_development_dependency(%q<rack-test>, [">= 0.5.6"])
27
- s.add_development_dependency(%q<rake>, ["~>0.9.2"])
27
+ s.add_development_dependency(%q<rake>, ["~>12.3.3"])
28
28
  s.add_development_dependency(%q<rdoc>, ["~> 4.0.1"])
29
29
  s.add_development_dependency(%q<rspec>, ["~> 3.0"])
30
30
  end
@@ -34,6 +34,17 @@ describe PDFKit::Configuration do
34
34
  expect(subject).to receive(:`).with('which wkhtmltopdf').and_return("c:\\windows\\path.exe\n")
35
35
  expect(subject.wkhtmltopdf).to eq('c:\windows\path.exe')
36
36
  end
37
+
38
+ it "returns last line of 'bundle exec which' output" do
39
+ # Happens when the user does not have a HOME directory on their system and runs bundler < 2
40
+ expect(subject).to receive(:`).with('bundle exec which wkhtmltopdf').and_return(<<~EOT
41
+ `/home/myuser` is not a directory.
42
+ Bundler will use `/tmp/bundler/home/myuser' as your home directory temporarily.
43
+ /usr/bin/wkhtmltopdf
44
+ EOT
45
+ )
46
+ expect(subject.wkhtmltopdf).to eq('/usr/bin/wkhtmltopdf')
47
+ end
37
48
  end
38
49
 
39
50
  context "when running without bundler" do
@@ -343,6 +343,20 @@ describe PDFKit::Middleware do
343
343
  end
344
344
 
345
345
  describe ":disposition" do
346
+ describe "doesn't overwrite existing value" do
347
+ let(:headers) do
348
+ super().merge({
349
+ 'Content-Disposition' => 'attachment; filename=report-20200101.pdf'
350
+ })
351
+ end
352
+
353
+ specify do
354
+ mock_app({}, { :disposition => 'inline' })
355
+ get 'http://www.example.org/public/test.pdf'
356
+ expect(last_response.headers["Content-Disposition"]).to eq('attachment; filename=report-20200101.pdf')
357
+ end
358
+ end
359
+
346
360
  describe "inline or blank" do
347
361
  context "default" do
348
362
  specify do
@@ -379,6 +393,16 @@ describe PDFKit::Middleware do
379
393
  end
380
394
  end
381
395
  end
396
+
397
+ describe "error handling" do
398
+ specify do
399
+ mock_app
400
+ allow(PDFKit).to receive(:new).and_raise(StandardError.new("Something went wrong"))
401
+ get 'http://www.example.org/public/test.pdf'
402
+ expect(last_response.status).to eq(500)
403
+ expect(last_response.body).to eq("Something went wrong")
404
+ end
405
+ end
382
406
  end
383
407
 
384
408
  describe "remove .pdf from PATH_INFO and REQUEST_URI" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4.2
4
+ version: 0.8.4.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Pace
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-01 00:00:00.000000000 Z
12
+ date: 2020-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 0.9.2
62
+ version: 12.3.3
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 0.9.2
69
+ version: 12.3.3
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rdoc
72
72
  requirement: !ruby/object:Gem::Requirement