galakei 0.14.2 → 0.14.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,12 @@ module Galakei::Email
41
41
  doc.css("head").each do |node|
42
42
  node.unlink
43
43
  end
44
+ doc.css("img").each do |node|
45
+ if node['src'] !~ /^cid:/
46
+ node.after(node['alt']) if node['alt']
47
+ node.unlink
48
+ end
49
+ end
44
50
  encoding = doc.meta_encoding || "UTF-8"
45
51
  res = "<html><head>"
46
52
  res << "<meta http-equiv=\"Content-type\" content=\"text/html;charset=#{encoding}\" />"
@@ -1,4 +1,4 @@
1
1
  module Galakei
2
2
  # The version of Galakei you are using
3
- VERSION = "0.14.2"
3
+ VERSION = "0.14.3"
4
4
  end
@@ -40,8 +40,10 @@ MSG=<<EOT
40
40
  <font size=4 color="#009900">
41
41
  GREEEEEEN
42
42
  </font>
43
+ <img src="http://someurl.com/someimage.png"/>
43
44
  <a href="http://dragonmobile.nuancemobiledeveloper.com/"><img src="cid:image-attachment-id" alt=""/></a>this was an image
44
45
  <br/>
46
+ This is <img src="http://someurl.com/someimage.png" alt="someimage"/>...
45
47
  And now, <a href="ftp://some.ftpsite.com/">Downloadz youz warez herez!</a>
46
48
  </html>
47
49
  EOT
@@ -60,7 +62,6 @@ describe Galakei::Email do
60
62
  sanitized_mail.should =~ /<br>/m
61
63
  sanitized_mail.should =~ /<blink>/m
62
64
  sanitized_mail.should =~ /<marquee behaviour=/m
63
- sanitized_mail.should =~ /<img src=.*cid/m
64
65
  sanitized_mail.should =~ /<a href=/m
65
66
  end
66
67
 
@@ -69,6 +70,12 @@ describe Galakei::Email do
69
70
  sanitized_mail.should_not =~ /<table>/
70
71
  end
71
72
 
73
+ it "should handle images" do
74
+ sanitized_mail.should =~ /<img src=.*cid/m
75
+ sanitized_mail.should_not =~ /<img src=.*http/m
76
+ sanitized_mail.should match("This is someimage...")
77
+ end
78
+
72
79
  it "should not have unsupported protocols" do
73
80
  sanitized_mail.should_not =~ /ftpsite/
74
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: galakei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.14.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-07-11 00:00:00.000000000 Z
14
+ date: 2012-07-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: actionpack