pdfkit 0.8.4.3.1 → 0.8.4.3.2

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: 1abe171f52890a9f122ae67cfc5c743ac486414bf6ffe78a72d767fccb7b43a6
4
- data.tar.gz: c979fcb4caa6d667be6b2f636e1acff3e4edaa59bf9e5ce45a709225fd4a3491
3
+ metadata.gz: a9763236251a08873c269bb76fa8cbc81e64111a9bd94ea7a167c0e96ad1e0dc
4
+ data.tar.gz: ab65d5b9648ec671a22191cf7eca7b14d6c4b07917e45adf479046360f7adfd7
5
5
  SHA512:
6
- metadata.gz: 70ac2e72c5aab61b4cfffe9bd26da109dee62286f8486d3596522dff5c0eb9b9ae5c1886b53d2b979247b2b6f38d9e8de07344d4963b8f1109879fd077550d0a
7
- data.tar.gz: 28c303321d80381c13e3071442cfd9652469e8c15cd977224762ddb93342ec3f5bed8be6e9b014f771490f38f365b7d3b21d771ead7931b751b7eee1cebf962f
6
+ metadata.gz: 8ce66b221fce28fb3be395a199fdb4fc3c660a1702302c4b453bc40f39033cadc41fff9ea8a5f0e612f12a1040fbdad31e738823c6d9cf3ea2456a9ebf55b999
7
+ data.tar.gz: 73827642f8a0d5a87745eb9d853f9a9a9e0d62ea7ab9f31e552be71cba2c4ce7b340da992ab0eabd145a0fbb6395a30d953396fc1bf25f7410db5df9572eb6e1
@@ -0,0 +1,19 @@
1
+ name: Release Drafter
2
+
3
+ on:
4
+ push:
5
+ # branches to consider in the event; optional, defaults to all
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ update_release_draft:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ # Drafts your next Release notes as Pull Requests are merged into "master"
14
+ - uses: release-drafter/release-drafter@v5
15
+ with:
16
+ # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
17
+ # config-name: my-config.yml
18
+ env:
19
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -1,3 +1,8 @@
1
+ 2020-08-16
2
+ =================
3
+ * Bump to 0.8.4.3.2
4
+ * Reduce scope of middleware exception handling (#476)
5
+
1
6
  2020-07-05
2
7
  =================
3
8
  * Bump to 0.8.4.3.1
@@ -19,43 +19,42 @@ class PDFKit
19
19
  set_request_to_render_as_pdf(env) if render_as_pdf?
20
20
  status, headers, response = @app.call(env)
21
21
 
22
- if rendering_pdf? && headers['Content-Type'] =~ /text\/html|application\/xhtml\+xml/
23
- body = response.respond_to?(:body) ? response.body : response.join
24
- body = body.join if body.is_a?(Array)
25
-
26
- root_url = root_url(env)
27
- protocol = protocol(env)
28
- options = @options.merge(root_url: root_url, protocol: protocol)
29
-
30
- if headers['PDFKit-javascript-delay']
31
- options.merge!(javascript_delay: headers.delete('PDFKit-javascript-delay').to_i)
32
- end
33
-
34
- body = PDFKit.new(body, options).to_pdf
35
- response = [body]
36
-
37
- if headers['PDFKit-save-pdf']
38
- File.open(headers['PDFKit-save-pdf'], 'wb') { |file| file.write(body) } rescue nil
39
- headers.delete('PDFKit-save-pdf')
22
+ begin
23
+ if rendering_pdf? && headers['Content-Type'] =~ /text\/html|application\/xhtml\+xml/
24
+ body = response.respond_to?(:body) ? response.body : response.join
25
+ body = body.join if body.is_a?(Array)
26
+
27
+ root_url = root_url(env)
28
+ protocol = protocol(env)
29
+ options = @options.merge(root_url: root_url, protocol: protocol)
30
+
31
+ if headers['PDFKit-javascript-delay']
32
+ options.merge!(javascript_delay: headers.delete('PDFKit-javascript-delay').to_i)
33
+ end
34
+
35
+ body = PDFKit.new(body, options).to_pdf
36
+ response = [body]
37
+
38
+ if headers['PDFKit-save-pdf']
39
+ File.open(headers['PDFKit-save-pdf'], 'wb') { |file| file.write(body) } rescue nil
40
+ headers.delete('PDFKit-save-pdf')
41
+ end
42
+
43
+ unless @caching
44
+ # Do not cache PDFs
45
+ headers.delete('ETag')
46
+ headers.delete('Cache-Control')
47
+ end
48
+
49
+ headers['Content-Length'] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
50
+ headers['Content-Type'] = 'application/pdf'
51
+ headers['Content-Disposition'] ||= @conditions[:disposition] || 'inline'
40
52
  end
41
-
42
- unless @caching
43
- # Do not cache PDFs
44
- headers.delete('ETag')
45
- headers.delete('Cache-Control')
46
- end
47
-
48
- headers['Content-Length'] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
49
- headers['Content-Type'] = 'application/pdf'
50
- headers['Content-Disposition'] ||= @conditions[:disposition] || 'inline'
53
+ rescue StandardError => e
54
+ status = 500
55
+ response = [e.message]
51
56
  end
52
57
 
53
- [status, headers, response]
54
-
55
- rescue StandardError => e
56
- status = 500
57
- response = [e.message]
58
-
59
58
  [status, headers, response]
60
59
  end
61
60
 
@@ -1,3 +1,3 @@
1
1
  class PDFKit
2
- VERSION = '0.8.4.3.1'
2
+ VERSION = '0.8.4.3.2'
3
3
  end
@@ -395,12 +395,27 @@ describe PDFKit::Middleware do
395
395
  end
396
396
 
397
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")
398
+ let(:error) { StandardError.new("Something went wrong") }
399
+
400
+ context "errors raised by PDF generation" do
401
+ specify do
402
+ mock_app
403
+ allow(PDFKit).to receive(:new).and_raise(error)
404
+ get 'http://www.example.org/public/test.pdf'
405
+ expect(last_response.status).to eq(500)
406
+ expect(last_response.body).to eq(error.message)
407
+ end
408
+ end
409
+
410
+ context "errors raised upstream" do
411
+ specify do
412
+ mock_app
413
+ allow(@app).to receive(:call).and_raise(error)
414
+
415
+ expect {
416
+ get 'http://www.example.org/public/test.pdf'
417
+ }.to raise_error(error)
418
+ end
404
419
  end
405
420
  end
406
421
  end
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.3.1
4
+ version: 0.8.4.3.2
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-07-06 00:00:00.000000000 Z
12
+ date: 2020-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -103,6 +103,7 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - ".document"
106
+ - ".github/workflows/release-drafter.yml"
106
107
  - ".github/workflows/stale.yml"
107
108
  - ".gitignore"
108
109
  - ".rspec"