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 +4 -4
- data/.github/workflows/release-drafter.yml +19 -0
- data/CHANGELOG.md +5 -0
- data/lib/pdfkit/middleware.rb +33 -34
- data/lib/pdfkit/version.rb +1 -1
- data/spec/middleware_spec.rb +21 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9763236251a08873c269bb76fa8cbc81e64111a9bd94ea7a167c0e96ad1e0dc
|
4
|
+
data.tar.gz: ab65d5b9648ec671a22191cf7eca7b14d6c4b07917e45adf479046360f7adfd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 }}
|
data/CHANGELOG.md
CHANGED
data/lib/pdfkit/middleware.rb
CHANGED
@@ -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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
43
|
-
|
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
|
|
data/lib/pdfkit/version.rb
CHANGED
data/spec/middleware_spec.rb
CHANGED
@@ -395,12 +395,27 @@ describe PDFKit::Middleware do
|
|
395
395
|
end
|
396
396
|
|
397
397
|
describe "error handling" do
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
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.
|
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-
|
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"
|