metamagic 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/metamagic/tag.rb +4 -4
- data/lib/metamagic/tags/meta_tag.rb +1 -1
- data/lib/metamagic/tags/title_tag.rb +1 -1
- data/lib/metamagic/version.rb +1 -1
- data/test/meta_tag_test.rb +14 -0
- data/test/metamagic_test.rb +7 -0
- data/test/title_tag_test.rb +42 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3785bc6edacf42b58b3da6a84e82067f9c740ac8
|
4
|
+
data.tar.gz: 45c1275787928af7cf48adbc35e4035c55d0558f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b15f67940db99c9a8a637094df1d87f85ae088d7f8a9c613ec095f636b813d8137a70d535ada796518301c2d2d2a41c12fe38698f8761a4ac8d63056a53f36d
|
7
|
+
data.tar.gz: 8f4bb4af01686c7adce5374216ebb9322c62ea7d31696962c8b22b3bf76e304b4802f6d6fdd9fa87d77b09135692183a5adcaaa759c86ea735190653c135c1a9
|
data/CHANGELOG.md
CHANGED
data/lib/metamagic/tag.rb
CHANGED
@@ -31,13 +31,13 @@ module Metamagic
|
|
31
31
|
when Symbol
|
32
32
|
send(template)
|
33
33
|
when String
|
34
|
-
template.gsub(/:\w+/) do |key|
|
35
|
-
send(key[1..-1])
|
36
|
-
end
|
34
|
+
ERB::Util.html_escape(template).gsub(/:\w+/) do |key|
|
35
|
+
ERB::Util.html_escape(send(key[1..-1]))
|
36
|
+
end.html_safe
|
37
37
|
else
|
38
38
|
raise "Unknown template type #{template.class}."
|
39
39
|
end
|
40
|
-
end.flatten.compact.uniq
|
40
|
+
end.flatten.compact.uniq.map { |value| ERB::Util.html_escape(value) }
|
41
41
|
end
|
42
42
|
|
43
43
|
def ==(other)
|
data/lib/metamagic/version.rb
CHANGED
data/test/meta_tag_test.rb
CHANGED
@@ -76,4 +76,18 @@ class MetaTagTest < ActionView::TestCase
|
|
76
76
|
assert_equal %{<meta content="added, keywords, default, from, layout" name="keywords" />},
|
77
77
|
metamagic(keywords: [:keywords, "added", "default", "keywords", "from", "layout"])
|
78
78
|
end
|
79
|
+
|
80
|
+
test "html safe keywords" do
|
81
|
+
keywords ["one", "two → test".html_safe, "three"]
|
82
|
+
|
83
|
+
assert_equal %{<meta content="one, two → test, three" name="keywords" />},
|
84
|
+
metamagic
|
85
|
+
end
|
86
|
+
|
87
|
+
test "html unsafe keywords" do
|
88
|
+
keywords ["one", "two → test", "three"]
|
89
|
+
|
90
|
+
assert_equal %{<meta content="one, two &rarr; test, three" name="keywords" />},
|
91
|
+
metamagic
|
92
|
+
end
|
79
93
|
end
|
data/test/metamagic_test.rb
CHANGED
@@ -51,6 +51,13 @@ class MetamagicTest < ActionView::TestCase
|
|
51
51
|
metamagic
|
52
52
|
end
|
53
53
|
|
54
|
+
test "not adding templates from views" do
|
55
|
+
title "This is a :nonexistent_key"
|
56
|
+
|
57
|
+
assert_equal %{<title>This is a :nonexistent_key</title>},
|
58
|
+
metamagic
|
59
|
+
end
|
60
|
+
|
54
61
|
test "sorting tags" do
|
55
62
|
twitter card: :summary
|
56
63
|
og image: "http://test.com/image.png"
|
data/test/title_tag_test.rb
CHANGED
@@ -79,6 +79,48 @@ class TitleTagTest < ActionView::TestCase
|
|
79
79
|
metamagic(site: "My Site", title: -> { meta_title_for(site, title) })
|
80
80
|
end
|
81
81
|
|
82
|
+
test "html safe titles" do
|
83
|
+
title "My Site → Test".html_safe
|
84
|
+
|
85
|
+
assert_equal %{<title>My Site → Test</title>},
|
86
|
+
metamagic
|
87
|
+
end
|
88
|
+
|
89
|
+
test "html safe titles in template" do
|
90
|
+
title "Test → Test".html_safe
|
91
|
+
|
92
|
+
assert_equal %{<title>Test → Test - My Site</title>},
|
93
|
+
metamagic(title: ":title - :site", site: "My Site")
|
94
|
+
end
|
95
|
+
|
96
|
+
test "html unsafe titles" do
|
97
|
+
title "My Site → Test"
|
98
|
+
|
99
|
+
assert_equal %{<title>My Site &rarr; Test</title>},
|
100
|
+
metamagic
|
101
|
+
end
|
102
|
+
|
103
|
+
test "html unsafe titles in template" do
|
104
|
+
title "Test → Test"
|
105
|
+
|
106
|
+
assert_equal %{<title>Test &rarr; Test - My Site</title>},
|
107
|
+
metamagic(title: ":title - :site", site: "My Site")
|
108
|
+
end
|
109
|
+
|
110
|
+
test "html safe title template" do
|
111
|
+
title "Test Title"
|
112
|
+
|
113
|
+
assert_equal %{<title>Test Title → My Site</title>},
|
114
|
+
metamagic(title: ":title → :site".html_safe, site: "My Site")
|
115
|
+
end
|
116
|
+
|
117
|
+
test "html unsafe title template" do
|
118
|
+
title "Test Title"
|
119
|
+
|
120
|
+
assert_equal %{<title>Test Title &rarr; My Site</title>},
|
121
|
+
metamagic(title: ":title → :site", site: "My Site")
|
122
|
+
end
|
123
|
+
|
82
124
|
test "deprecated title_template option" do
|
83
125
|
title "Test Title"
|
84
126
|
|