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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 824738b3d4f198d080bb590e5db7489da39ffb40f5f8c24b97652793160ac0d9
4
- data.tar.gz: 963701136ddf00dd42502b2d564135c675ae1ae313c6cd40d8dd92761a70b3af
3
+ metadata.gz: dd9ab1711dcc1f5dc4c9ec2b0f5a203394cc8276291f34bd59230dd832c6b51c
4
+ data.tar.gz: 0ec141cfe484aea9ae00488c34da32573f8f84d7ae3a5a3d5c954a0d4acfbee5
5
5
  SHA512:
6
- metadata.gz: 6340e287849a0c43b8883cc1f2b78138fc5628fd2da4670c5f5d8a150632b56dbf27c9716bea49c1007cc2359148a4b3c1af1fed8c264ff89cf3d379976bfe30
7
- data.tar.gz: b1b4f6d302ec4c407ebac2dfcc6bf3d72d7882520ba407bdb0d2b0316684ddcc09d3eecf0967305976292210a21304dc9b399fa39a9c4055ced27c5b7b8c1677
6
+ metadata.gz: d8cf1754028c05b1dab1f382c91b86672a8a2808bbabbe66132fdb78501a731b1a651b5d276c0818efba1b537a685d2f55cb2a281935edf8c7b5b58c3aed1f1a
7
+ data.tar.gz: 93f26e92cc31dd7f4fdaf1d5a20c2b2c5463d66588bc465bfacbfa4aecbbbe19662b1e605c1ac69593e1974fc0d606ff92298cfdace4c55313d977b87d128fc4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 2022-10-17
2
+ =================
3
+ * Bump to 0.8.7.1
4
+ * Support non-lower-case Content-Type header provided by app (#516)
5
+
1
6
  2022-10-02
2
7
  =================
3
8
  * Bump to 0.8.7
@@ -22,7 +22,8 @@ class PDFKit
22
22
  status, headers, response = @app.call(env)
23
23
 
24
24
  begin
25
- if rendering_pdf? && headers['content-type'] =~ /text\/html|application\/xhtml\+xml/
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['content-type'] = 'application/pdf'
53
+ headers[content_type_header] = 'application/pdf'
53
54
  headers['content-disposition'] ||= @conditions[:disposition] || 'inline'
54
55
  end
55
56
  rescue StandardError => e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PDFKit
4
- VERSION = '0.8.7'
4
+ VERSION = '0.8.7.1'
5
5
  end
@@ -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-02 00:00:00.000000000 Z
12
+ date: 2022-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport