html-pipeline 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a991b217bf4c9c658d1843fe35e6a9ba989b180
4
- data.tar.gz: 24763a9cac62ba2047a64e2c42bfee4107e00ae3
3
+ metadata.gz: 18ebd2d23ad0e2b826d0f799544324f75efad1c4
4
+ data.tar.gz: c052603aa7e7dd3af1b9b75f55a52ad4be278fbf
5
5
  SHA512:
6
- metadata.gz: 8433da8334030909b29622d615aa693117c89fdcb06ce581d2dfae7e1a14dee705e3c60fbfbebb8d1c1227ee80d279aded108a1d7491305279d0994195b03c2c
7
- data.tar.gz: 34cd18428fdf6b408347ffc6d5e5eb95e6f6ee0dfff098b2a5114ecbb73bc4f78931baabaee145abf070cd2b2df6e1edfb6d28a9b6ad49d53c5ccb156db006d2
6
+ metadata.gz: f5177792a0de9b78ccdfeb86c2b335ed25dcc83a2e10db7c8fa34236ec61e6746fb358c593fc156739c338144332e7e6f193300a6399485e1ea5210af3424ff2
7
+ data.tar.gz: 905067a669f37813c52858536ebda8af639ba6b3b1929b361acd4f9460d06881f922db57f40033f2eb15b7eb061a31b365d497e0b19b6863ebbf42401bc7dc35
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.4.0
4
+
5
+ * Fix CamoFilter double entity encoding. #101 josh
6
+
3
7
  ## 1.3.0
4
8
 
5
9
  1.2.0 didn't actually include the following changes. Yanked that release.
@@ -25,10 +25,11 @@ module HTML
25
25
  return unless asset_proxy_enabled?
26
26
 
27
27
  doc.search("img").each do |element|
28
- next if element['src'].nil?
28
+ original_src = element['src']
29
+ next unless original_src
29
30
 
30
31
  begin
31
- uri = URI.parse(element['src'])
32
+ uri = URI.parse(original_src)
32
33
  rescue Exception
33
34
  next
34
35
  end
@@ -36,8 +37,8 @@ module HTML
36
37
  next if uri.host.nil?
37
38
  next if asset_host_whitelisted?(uri.host)
38
39
 
39
- element['src'] = asset_proxy_url(uri.to_s)
40
- element['data-canonical-src'] = uri.to_s
40
+ element['src'] = asset_proxy_url(original_src)
41
+ element['data-canonical-src'] = original_src
41
42
  end
42
43
  doc
43
44
  end
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class Pipeline
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -15,51 +15,44 @@ class HTML::Pipeline::CamoFilterTest < Test::Unit::TestCase
15
15
 
16
16
  def test_camouflaging_http_image_urls
17
17
  orig = %(<p><img src="http://twitter.com/img.png"></p>)
18
- assert_includes 'img src="' + @asset_proxy_url,
19
- CamoFilter.call(orig, @options).to_s
20
- assert_includes 'data-canonical-src="http://twitter.com/img.png"',
18
+ assert_equal %(<p><img src="https//assets.example.org/a5ad43494e343b20d745586282be61ff530e6fa0/687474703a2f2f747769747465722e636f6d2f696d672e706e67" data-canonical-src="http://twitter.com/img.png"></p>),
21
19
  CamoFilter.call(orig, @options).to_s
22
20
  end
23
21
 
24
22
  def test_doesnt_rewrite_dotcom_image_urls
25
23
  orig = %(<p><img src="https://github.com/img.png"></p>)
26
- assert_equal "<p><img src=\"https://github.com/img.png\"></p>",
27
- CamoFilter.call(orig, @options).to_s
24
+ assert_equal orig, CamoFilter.call(orig, @options).to_s
28
25
  end
29
26
 
30
27
  def test_doesnt_rewrite_dotcom_subdomain_image_urls
31
28
  orig = %(<p><img src="https://raw.github.com/img.png"></p>)
32
- assert_equal "<p><img src=\"https://raw.github.com/img.png\"></p>",
33
- CamoFilter.call(orig, @options).to_s
29
+ assert_equal orig, CamoFilter.call(orig, @options).to_s
34
30
  end
35
31
 
36
32
  def test_doesnt_rewrite_dotcom_subsubdomain_image_urls
37
33
  orig = %(<p><img src="https://f.assets.github.com/img.png"></p>)
38
- assert_equal "<p><img src=\"https://f.assets.github.com/img.png\"></p>",
39
- CamoFilter.call(orig, @options).to_s
34
+ assert_equal orig, CamoFilter.call(orig, @options).to_s
40
35
  end
41
36
 
42
37
  def test_camouflaging_github_prefixed_image_urls
43
38
  orig = %(<p><img src="https://notgithub.com/img.png"></p>)
44
- assert_includes 'img src="' + @asset_proxy_url,
39
+ assert_equal %(<p><img src="https//assets.example.org/5d4a96c69713f850520538e04cb9661035cfb534/68747470733a2f2f6e6f746769746875622e636f6d2f696d672e706e67" data-canonical-src="https://notgithub.com/img.png"></p>),
45
40
  CamoFilter.call(orig, @options).to_s
46
41
  end
47
42
 
48
43
  def test_doesnt_rewrite_absolute_image_urls
49
44
  orig = %(<p><img src="/img.png"></p>)
50
- assert_equal "<p><img src=\"/img.png\"></p>",
51
- CamoFilter.call(orig, @options).to_s
45
+ assert_equal orig, CamoFilter.call(orig, @options).to_s
52
46
  end
53
47
 
54
48
  def test_doesnt_rewrite_relative_image_urls
55
49
  orig = %(<p><img src="img.png"></p>)
56
- assert_equal "<p><img src=\"img.png\"></p>",
57
- CamoFilter.call(orig, @options).to_s
50
+ assert_equal orig, CamoFilter.call(orig, @options).to_s
58
51
  end
59
52
 
60
53
  def test_camouflaging_https_image_urls
61
54
  orig = %(<p><img src="https://foo.com/img.png"></p>)
62
- assert_includes 'img src="' + @asset_proxy_url,
55
+ assert_equal %(<p><img src="https//assets.example.org/3c5c6dc74fd6592d2596209dfcb8b7e5461383c8/68747470733a2f2f666f6f2e636f6d2f696d672e706e67" data-canonical-src="https://foo.com/img.png"></p>),
63
56
  CamoFilter.call(orig, @options).to_s
64
57
  end
65
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-14 00:00:00.000000000 Z
12
+ date: 2014-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri