pdfkit 0.8.7 → 0.8.7.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/pdfkit/middleware.rb +3 -2
- data/lib/pdfkit/version.rb +1 -1
- data/spec/middleware_spec.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd9ab1711dcc1f5dc4c9ec2b0f5a203394cc8276291f34bd59230dd832c6b51c
|
4
|
+
data.tar.gz: 0ec141cfe484aea9ae00488c34da32573f8f84d7ae3a5a3d5c954a0d4acfbee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8cf1754028c05b1dab1f382c91b86672a8a2808bbabbe66132fdb78501a731b1a651b5d276c0818efba1b537a685d2f55cb2a281935edf8c7b5b58c3aed1f1a
|
7
|
+
data.tar.gz: 93f26e92cc31dd7f4fdaf1d5a20c2b2c5463d66588bc465bfacbfa4aecbbbe19662b1e605c1ac69593e1974fc0d606ff92298cfdace4c55313d977b87d128fc4
|
data/CHANGELOG.md
CHANGED
data/lib/pdfkit/middleware.rb
CHANGED
@@ -22,7 +22,8 @@ class PDFKit
|
|
22
22
|
status, headers, response = @app.call(env)
|
23
23
|
|
24
24
|
begin
|
25
|
-
|
25
|
+
content_type_header = headers.has_key?('Content-Type') ? 'Content-Type' : 'content-type'
|
26
|
+
if rendering_pdf? && headers[content_type_header] =~ /text\/html|application\/xhtml\+xml/
|
26
27
|
body = response.respond_to?(:body) ? response.body : response.join
|
27
28
|
body = body.join if body.is_a?(Array)
|
28
29
|
|
@@ -49,7 +50,7 @@ class PDFKit
|
|
49
50
|
end
|
50
51
|
|
51
52
|
headers['content-length'] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
|
52
|
-
headers[
|
53
|
+
headers[content_type_header] = 'application/pdf'
|
53
54
|
headers['content-disposition'] ||= @conditions[:disposition] || 'inline'
|
54
55
|
end
|
55
56
|
rescue StandardError => e
|
data/lib/pdfkit/version.rb
CHANGED
data/spec/middleware_spec.rb
CHANGED
@@ -422,6 +422,29 @@ describe PDFKit::Middleware do
|
|
422
422
|
end
|
423
423
|
end
|
424
424
|
|
425
|
+
describe "content type header" do
|
426
|
+
before { mock_app }
|
427
|
+
|
428
|
+
context "lower case" do
|
429
|
+
specify "header gets correctly updated" do
|
430
|
+
get 'http://www.example.org/public/test.pdf'
|
431
|
+
expect(last_response.headers["content-type"]).to eq("application/pdf")
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
context "mixed case" do
|
436
|
+
let(:headers) do
|
437
|
+
{'Content-Type' => "text/html"}
|
438
|
+
end
|
439
|
+
|
440
|
+
specify "header gets correctly updated" do
|
441
|
+
pending("this test only applies to rack 2.x and is rejected by rack 3.x") if Rack.release >= "3.0.0"
|
442
|
+
get 'http://www.example.org/public/test.pdf'
|
443
|
+
expect(last_response.headers["Content-Type"]).to eq("application/pdf")
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
425
448
|
describe "remove .pdf from PATH_INFO and REQUEST_URI" do
|
426
449
|
before { mock_app }
|
427
450
|
|
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.7
|
4
|
+
version: 0.8.7.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: 2022-10-
|
12
|
+
date: 2022-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|