open_graph_reader 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/open_graph_reader.rb +10 -10
- data/lib/open_graph_reader/base.rb +9 -2
- data/lib/open_graph_reader/builder.rb +96 -44
- data/lib/open_graph_reader/configuration.rb +36 -10
- data/lib/open_graph_reader/definitions.rb +32 -33
- data/lib/open_graph_reader/fetcher.rb +13 -18
- data/lib/open_graph_reader/object.rb +7 -9
- data/lib/open_graph_reader/object/dsl.rb +58 -43
- data/lib/open_graph_reader/object/dsl/types.rb +51 -35
- data/lib/open_graph_reader/object/registry.rb +3 -3
- data/lib/open_graph_reader/parser.rb +30 -29
- data/lib/open_graph_reader/parser/graph.rb +18 -6
- data/lib/open_graph_reader/version.rb +1 -1
- data/spec/fixtures/real_world/invalid_article_author.html +299 -0
- data/spec/fixtures/real_world/invalid_datetime.html +301 -0
- data/spec/fixtures/real_world/url_path.html +1871 -0
- data/spec/integration/invalid_examples_spec.rb +21 -21
- data/spec/integration/real_world_spec.rb +335 -72
- data/spec/integration/valid_examples_spec.rb +7 -6
- data/spec/open_graph_reader_spec.rb +6 -6
- data/spec/spec_helper.rb +5 -8
- metadata +9 -3
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "invalid examples" do
|
4
4
|
describe "plain" do
|
5
5
|
it "says there are no tags" do
|
6
6
|
expect {
|
7
|
-
OpenGraphReader.parse! example_html
|
7
|
+
OpenGraphReader.parse! example_html "plain"
|
8
8
|
}.to raise_error OpenGraphReader::NoOpenGraphDataError, /OpenGraph tags/
|
9
9
|
end
|
10
10
|
|
@@ -12,7 +12,7 @@ RSpec.describe "invalid examples" do
|
|
12
12
|
OpenGraphReader.config.synthesize_title = true
|
13
13
|
|
14
14
|
expect {
|
15
|
-
OpenGraphReader.parse! example_html
|
15
|
+
OpenGraphReader.parse! example_html "plain"
|
16
16
|
}.to raise_error OpenGraphReader::NoOpenGraphDataError, /OpenGraph tags/
|
17
17
|
end
|
18
18
|
end
|
@@ -20,14 +20,14 @@ RSpec.describe "invalid examples" do
|
|
20
20
|
describe "min" do
|
21
21
|
it "has missing required properties" do
|
22
22
|
expect {
|
23
|
-
OpenGraphReader.parse! example_html
|
23
|
+
OpenGraphReader.parse! example_html "min"
|
24
24
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Missing required/
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns what's there if required property validation is disabled" do
|
28
28
|
OpenGraphReader.config.validate_required = false
|
29
|
-
object = OpenGraphReader.parse! example_html
|
30
|
-
expect(object.og.site_name).to
|
29
|
+
object = OpenGraphReader.parse! example_html "min"
|
30
|
+
expect(object.og.site_name).to eq "Open Graph protocol examples"
|
31
31
|
expect(object.og.description).to eq "Content not on page"
|
32
32
|
end
|
33
33
|
end
|
@@ -35,7 +35,7 @@ RSpec.describe "invalid examples" do
|
|
35
35
|
describe "filters/xss-image" do
|
36
36
|
it "errors on the invaid URL in strict mode" do
|
37
37
|
expect {
|
38
|
-
OpenGraphReader.parse! example_html
|
38
|
+
OpenGraphReader.parse! example_html "filters/xss-image"
|
39
39
|
}.to raise_error OpenGraphReader::InvalidObjectError, /does not start with http/
|
40
40
|
end
|
41
41
|
end
|
@@ -43,7 +43,7 @@ RSpec.describe "invalid examples" do
|
|
43
43
|
describe "errors/article-date" do
|
44
44
|
it "has an incorrectly formatted date" do
|
45
45
|
expect {
|
46
|
-
OpenGraphReader.parse! example_html
|
46
|
+
OpenGraphReader.parse! example_html "errors/article-date"
|
47
47
|
}.to raise_error OpenGraphReader::InvalidObjectError, /ISO8601 datetime expected/
|
48
48
|
end
|
49
49
|
end
|
@@ -51,7 +51,7 @@ RSpec.describe "invalid examples" do
|
|
51
51
|
describe "errors/book-author" do
|
52
52
|
it "doesn't have a profile object as author" do
|
53
53
|
expect {
|
54
|
-
OpenGraphReader.parse! example_html
|
54
|
+
OpenGraphReader.parse! example_html "errors/book-author"
|
55
55
|
}.to raise_error OpenGraphReader::InvalidObjectError, /does not start with http/
|
56
56
|
end
|
57
57
|
end
|
@@ -59,7 +59,7 @@ RSpec.describe "invalid examples" do
|
|
59
59
|
describe "errors/gender" do
|
60
60
|
it "doesn't have a valid gender" do
|
61
61
|
expect {
|
62
|
-
OpenGraphReader.parse! example_html
|
62
|
+
OpenGraphReader.parse! example_html "errors/gender"
|
63
63
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Expected one of/
|
64
64
|
end
|
65
65
|
end
|
@@ -69,16 +69,16 @@ RSpec.describe "invalid examples" do
|
|
69
69
|
OpenGraphReader.config.strict = true
|
70
70
|
|
71
71
|
expect {
|
72
|
-
OpenGraphReader.parse! example_html
|
72
|
+
OpenGraphReader.parse! example_html "errors/geo"
|
73
73
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Undefined property/
|
74
74
|
end
|
75
75
|
|
76
76
|
it "parses in default mode" do
|
77
|
-
object = OpenGraphReader.parse! example_html
|
77
|
+
object = OpenGraphReader.parse! example_html "errors/geo"
|
78
78
|
|
79
|
-
expect(object.og.type).to
|
80
|
-
expect(object.og.title).to
|
81
|
-
expect(object.og.url).to
|
79
|
+
expect(object.og.type).to eq "website"
|
80
|
+
expect(object.og.title).to eq "Open Graph protocol 1.0 location data"
|
81
|
+
expect(object.og.url).to eq "http://examples.opengraphprotocol.us/errors/geo.html"
|
82
82
|
expect(object.og.image.url).to eq "http://examples.opengraphprotocol.us/media/images/50.png"
|
83
83
|
end
|
84
84
|
end
|
@@ -88,16 +88,16 @@ RSpec.describe "invalid examples" do
|
|
88
88
|
OpenGraphReader.config.strict = true
|
89
89
|
|
90
90
|
expect {
|
91
|
-
OpenGraphReader.parse! example_html
|
91
|
+
OpenGraphReader.parse! example_html "errors/type"
|
92
92
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Undefined type/
|
93
93
|
end
|
94
94
|
|
95
95
|
it "parses the known properties" do
|
96
|
-
object = OpenGraphReader.parse! example_html
|
96
|
+
object = OpenGraphReader.parse! example_html "errors/type"
|
97
97
|
|
98
|
-
expect(object.og.type).to
|
99
|
-
expect(object.og.title).to
|
100
|
-
expect(object.og.url).to
|
98
|
+
expect(object.og.type).to eq "fubar"
|
99
|
+
expect(object.og.title).to eq "Undefined global type"
|
100
|
+
expect(object.og.url).to eq "http://examples.opengraphprotocol.us/errors/type.html"
|
101
101
|
expect(object.og.image.url).to eq "http://examples.opengraphprotocol.us/media/images/50.png"
|
102
102
|
end
|
103
103
|
end
|
@@ -105,7 +105,7 @@ RSpec.describe "invalid examples" do
|
|
105
105
|
describe "errors/video-duration" do
|
106
106
|
it "only accepts integers" do
|
107
107
|
expect {
|
108
|
-
OpenGraphReader.parse! example_html
|
108
|
+
OpenGraphReader.parse! example_html "errors/video-duration"
|
109
109
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Integer expected/
|
110
110
|
end
|
111
111
|
end
|
@@ -1,30 +1,33 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "real world examples" do
|
4
4
|
describe "mixed_case_properties" do
|
5
5
|
it "parses" do
|
6
6
|
expect {
|
7
|
-
OpenGraphReader.parse! fixture_html
|
7
|
+
OpenGraphReader.parse! fixture_html "real_world/mixed_case_properties"
|
8
8
|
}.to_not raise_error
|
9
9
|
end
|
10
10
|
|
11
11
|
it "assigns the right attributes" do
|
12
|
-
object = OpenGraphReader.parse fixture_html
|
12
|
+
object = OpenGraphReader.parse fixture_html "real_world/mixed_case_properties"
|
13
13
|
|
14
|
-
expect(object.og.title).to
|
15
|
-
expect(object.og.type).to
|
14
|
+
expect(object.og.title).to eq "Eine Million Unterschriften gegen TTIP"
|
15
|
+
expect(object.og.type).to eq "website"
|
16
16
|
expect(object.og.locale.to_s).to eq "de_DE"
|
17
|
-
expect(object.og.url).to
|
18
|
-
expect(object.og.site_name).to
|
19
|
-
expect(object.og.image.url).to
|
20
|
-
expect(object.og.description).to eq
|
17
|
+
expect(object.og.url).to eq "http://www.heise.de/tp/artikel/43/43516/"
|
18
|
+
expect(object.og.site_name).to eq "Telepolis"
|
19
|
+
expect(object.og.image.url).to eq "http://www.heise.de/tp/artikel/43/43516/43516_1.jpg"
|
20
|
+
expect(object.og.description).to eq(
|
21
|
+
"Ungenehmigte Bürgerinitiative will das Paket EU-Kommissionschef Juncker zum Geburtstag "\
|
22
|
+
"schenken"
|
23
|
+
)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
24
27
|
describe "missing_image" do
|
25
28
|
it "does not parse" do
|
26
29
|
expect {
|
27
|
-
OpenGraphReader.parse! fixture_html
|
30
|
+
OpenGraphReader.parse! fixture_html "real_world/missing_image"
|
28
31
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Missing required/
|
29
32
|
end
|
30
33
|
end
|
@@ -32,7 +35,7 @@ RSpec.describe "real world examples" do
|
|
32
35
|
describe "mixed_case_type" do
|
33
36
|
it "parses" do
|
34
37
|
expect {
|
35
|
-
OpenGraphReader.parse! fixture_html
|
38
|
+
OpenGraphReader.parse! fixture_html "real_world/mixed_case_type"
|
36
39
|
}.to_not raise_error
|
37
40
|
end
|
38
41
|
end
|
@@ -40,160 +43,420 @@ RSpec.describe "real world examples" do
|
|
40
43
|
describe "not_a_reference" do
|
41
44
|
it "does not parse" do
|
42
45
|
expect {
|
43
|
-
OpenGraphReader.parse! fixture_html
|
46
|
+
OpenGraphReader.parse! fixture_html "real_world/not_a_reference"
|
44
47
|
}.to raise_error OpenGraphReader::InvalidObjectError, /does not start with/
|
45
48
|
end
|
46
49
|
|
47
50
|
it "parses with reference validation turned of" do
|
48
51
|
OpenGraphReader.config.validate_references = false
|
49
|
-
object = OpenGraphReader.parse! fixture_html
|
50
|
-
|
51
|
-
expect(object.og.title).to
|
52
|
-
expect(object.og.type).to
|
53
|
-
expect(object.og.description).to
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
object = OpenGraphReader.parse! fixture_html "real_world/not_a_reference"
|
53
|
+
|
54
|
+
expect(object.og.title).to eq "Emergency call system for all new cars by 2018"
|
55
|
+
expect(object.og.type).to eq "article"
|
56
|
+
expect(object.og.description).to eq(
|
57
|
+
"The European Parliament and EU member states have agreed that new cars must be fitted"\
|
58
|
+
" with an automated system to alert emergency services in event of a crash."
|
59
|
+
)
|
60
|
+
expect(object.og.site_name).to eq "BBC News"
|
61
|
+
expect(object.og.url).to eq "http://www.bbc.co.uk/news/technology-30337272"
|
62
|
+
expect(object.og.image.url).to eq(
|
63
|
+
"http://news.bbcimg.co.uk/media/images/79520000/jpg/_79520623_79519885.jpg"
|
64
|
+
)
|
57
65
|
expect(object.article.author.to_s).to eq "BBC News"
|
58
|
-
expect(object.article.section).to
|
66
|
+
expect(object.article.section).to eq "Technology"
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
62
70
|
describe "unknown_type" do
|
63
71
|
it "parses" do
|
64
|
-
object = OpenGraphReader.parse! fixture_html
|
65
|
-
|
66
|
-
expect(object.og.url).to
|
67
|
-
expect(object.og.title).to
|
68
|
-
expect(object.og.image.url).to
|
69
|
-
|
72
|
+
object = OpenGraphReader.parse! fixture_html "real_world/unknown_type"
|
73
|
+
|
74
|
+
expect(object.og.url).to eq "http://www.instructables.com/id/Building-the-Open-Knit-machine/"
|
75
|
+
expect(object.og.title).to eq "Building the OpenKnit machine"
|
76
|
+
expect(object.og.image.url).to eq(
|
77
|
+
"http://cdn.instructables.com/FI2/D7XW/I2XTQWFE/FI2D7XWI2XTQWFE.RECTANGLE1.jpg"
|
78
|
+
)
|
79
|
+
expect(object.og.description).to eq(
|
80
|
+
"The OpenKnit machine is an open-source, low cost, digital fabrication tool developed by "\
|
81
|
+
"Gerard Rubio. The machine affords the user the opportunity to..."
|
82
|
+
)
|
70
83
|
end
|
71
84
|
|
72
85
|
it "does not parse in strict mode" do
|
73
86
|
OpenGraphReader.config.strict = true
|
74
87
|
|
75
88
|
expect {
|
76
|
-
OpenGraphReader.parse! fixture_html
|
89
|
+
OpenGraphReader.parse! fixture_html "real_world/unknown_type"
|
77
90
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Undefined type/
|
78
91
|
end
|
79
92
|
end
|
80
93
|
|
81
94
|
describe "undefined_property" do
|
82
95
|
it "parses (1)" do
|
83
|
-
object = OpenGraphReader.parse! fixture_html
|
96
|
+
object = OpenGraphReader.parse! fixture_html "real_world/undefined_property"
|
84
97
|
|
85
98
|
expect(object.og.locale.to_s).to eq "es_ES"
|
86
|
-
expect(object.og.type).to
|
87
|
-
expect(object.og.title).to
|
88
|
-
expect(object.og.description).to eq
|
89
|
-
|
90
|
-
|
91
|
-
|
99
|
+
expect(object.og.type).to eq "article"
|
100
|
+
expect(object.og.title).to eq "Profesores y campesinos amarran a infiltrados en marcha"
|
101
|
+
expect(object.og.description).to eq(
|
102
|
+
"Regeneración, 6 de diciembre de 2014.-Durante la marcha que realizan profesores y "\
|
103
|
+
"organizaciones campesinas sobre avenida Paseo de la Reforma, maestros de la Coordinadora "\
|
104
|
+
"Estatal de Trabajadores de la Educación en Guerrero (CETEG) ubicaron a 12 jóvenes como "\
|
105
|
+
"“infiltrados”, a quienes amarraron de las manos en una cadena humana para evitar que "\
|
106
|
+
"marchen con ellos, informó El …"
|
107
|
+
)
|
108
|
+
expect(object.og.url).to eq(
|
109
|
+
"http://regeneracion.mx/sociedad/profesores-y-campesinos-amarran-a-infiltrados-en-marcha/"
|
110
|
+
)
|
111
|
+
expect(object.og.site_name).to eq "Regeneración"
|
112
|
+
expect(object.og.image.url).to eq(
|
113
|
+
"http://regeneracion.mx/wp-content/uploads/2014/12/Infiltrados.jpg"
|
114
|
+
)
|
92
115
|
end
|
93
116
|
|
94
117
|
it "does not parse in strict mode (1)" do
|
95
118
|
OpenGraphReader.config.strict = true
|
96
119
|
|
97
120
|
expect {
|
98
|
-
OpenGraphReader.parse! fixture_html
|
121
|
+
OpenGraphReader.parse! fixture_html "real_world/undefined_property"
|
99
122
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Undefined property/
|
100
123
|
end
|
101
124
|
|
102
125
|
it "parses (2)" do
|
103
|
-
object = OpenGraphReader.parse! fixture_html
|
104
|
-
|
105
|
-
|
106
|
-
expect(object.og.
|
107
|
-
expect(object.og.
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
expect(object.og.
|
126
|
+
object = OpenGraphReader.parse! fixture_html "real_world/undefined_property_2"
|
127
|
+
|
128
|
+
expect(object.og.title).to eq "Emergency call system for all new cars by 2018"
|
129
|
+
expect(object.og.type).to eq "article"
|
130
|
+
expect(object.og.description).to eq(
|
131
|
+
"The European Parliament and EU member states have agreed that new cars must be fitted with"\
|
132
|
+
" an automated system to alert emergency services in event of a crash."
|
133
|
+
)
|
134
|
+
expect(object.og.site_name).to eq "BBC News"
|
135
|
+
expect(object.og.url).to eq "http://www.bbc.co.uk/news/technology-30337272"
|
136
|
+
expect(object.og.image.url).to eq(
|
137
|
+
"http://news.bbcimg.co.uk/media/images/79520000/jpg/_79520623_79519885.jpg"
|
138
|
+
)
|
112
139
|
end
|
113
140
|
|
114
141
|
it "does not parse in strict mode (2)" do
|
115
142
|
OpenGraphReader.config.strict = true
|
116
143
|
|
117
144
|
expect {
|
118
|
-
OpenGraphReader.parse! fixture_html
|
145
|
+
OpenGraphReader.parse! fixture_html "real_world/undefined_property_2"
|
119
146
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Undefined property/
|
120
147
|
end
|
121
148
|
end
|
122
149
|
|
123
150
|
describe "unknown_namespace" do
|
124
151
|
it "parses" do
|
125
|
-
object = OpenGraphReader.parse! fixture_html
|
126
|
-
|
127
|
-
expect(object.og.url).to
|
128
|
-
expect(object.og.title).to
|
129
|
-
expect(object.og.image.url).to
|
130
|
-
|
152
|
+
object = OpenGraphReader.parse! fixture_html "real_world/unknown_namespace"
|
153
|
+
|
154
|
+
expect(object.og.url).to eq "http://www.instructables.com/id/Building-the-Open-Knit-machine/"
|
155
|
+
expect(object.og.title).to eq "Building the OpenKnit machine"
|
156
|
+
expect(object.og.image.url).to eq(
|
157
|
+
"http://cdn.instructables.com/FI2/D7XW/I2XTQWFE/FI2D7XWI2XTQWFE.RECTANGLE1.jpg"
|
158
|
+
)
|
159
|
+
expect(object.og.description).to eq(
|
160
|
+
"The OpenKnit machine is an open-source, low cost, digital fabrication tool developed by "\
|
161
|
+
"Gerard Rubio. The machine affords the user the opportunity to..."
|
162
|
+
)
|
131
163
|
end
|
132
164
|
|
133
165
|
it "does not parse in strict mode" do
|
134
166
|
OpenGraphReader.config.strict = true
|
135
167
|
|
136
168
|
expect {
|
137
|
-
OpenGraphReader.parse! fixture_html
|
169
|
+
OpenGraphReader.parse! fixture_html "real_world/unknown_namespace"
|
138
170
|
}.to raise_error OpenGraphReader::InvalidObjectError, /is not a registered namespace/
|
139
171
|
end
|
140
172
|
end
|
141
173
|
|
142
|
-
|
143
174
|
describe "missing_title" do
|
144
175
|
it "does not parse" do
|
145
176
|
expect {
|
146
|
-
OpenGraphReader.parse! fixture_html
|
177
|
+
OpenGraphReader.parse! fixture_html "real_world/missing_title"
|
147
178
|
}.to raise_error OpenGraphReader::InvalidObjectError, /Missing required/
|
148
179
|
end
|
149
180
|
|
150
181
|
it "does parse when synthesizing titles" do
|
151
182
|
OpenGraphReader.config.synthesize_title = true
|
152
183
|
|
153
|
-
object = OpenGraphReader.parse! fixture_html
|
154
|
-
|
155
|
-
expect(object.og.type).to
|
156
|
-
expect(object.og.title).to
|
157
|
-
|
184
|
+
object = OpenGraphReader.parse! fixture_html "real_world/missing_title"
|
185
|
+
|
186
|
+
expect(object.og.type).to eq "website"
|
187
|
+
expect(object.og.title).to eq(
|
188
|
+
"Ultra Conservative Christian Lady Goes To Museum, Tries To Debunk Evolution, Fails Beyond"\
|
189
|
+
" Miserably | Geekologie"
|
190
|
+
)
|
191
|
+
expect(object.og.image.url).to eq(
|
192
|
+
"http://geekologie.com/assets_c/2014/11/crazy-lady-goes-to-the"\
|
193
|
+
"-museum-thumb-640x389-29314.jpg"
|
194
|
+
)
|
158
195
|
end
|
159
196
|
end
|
160
197
|
|
161
198
|
describe "image_path" do
|
162
199
|
it "does not parse" do
|
163
200
|
expect {
|
164
|
-
OpenGraphReader.parse! fixture_html
|
201
|
+
OpenGraphReader.parse! fixture_html "real_world/image_path"
|
165
202
|
}.to raise_error OpenGraphReader::InvalidObjectError, /does not start with/
|
166
203
|
end
|
167
204
|
|
168
205
|
it "parses with image paths turned on" do
|
169
206
|
OpenGraphReader.config.synthesize_image_url = true
|
170
207
|
|
171
|
-
object = OpenGraphReader.parse!
|
208
|
+
object = OpenGraphReader.parse!(
|
209
|
+
fixture_html("real_world/image_path"),
|
210
|
+
"http://fritzing.org/download/"
|
211
|
+
)
|
172
212
|
|
173
|
-
expect(object.og.title).to
|
174
|
-
expect(object.og.type).to
|
213
|
+
expect(object.og.title).to eq "Fritzing"
|
214
|
+
expect(object.og.type).to eq "website"
|
175
215
|
expect(object.og.image.url).to eq "http://fritzing.org/static/img/fritzing.png"
|
176
|
-
expect(object.og.url).to
|
216
|
+
expect(object.og.url).to eq "http://fritzing.org/"
|
177
217
|
end
|
178
218
|
end
|
179
219
|
|
180
220
|
describe "image_path_2" do
|
181
|
-
|
221
|
+
it "does not parse" do
|
182
222
|
expect {
|
183
|
-
OpenGraphReader.parse! fixture_html
|
223
|
+
OpenGraphReader.parse! fixture_html "real_world/image_path_2"
|
184
224
|
}.to raise_error OpenGraphReader::InvalidObjectError, /does not start with/
|
185
225
|
end
|
186
226
|
|
187
227
|
it "parses with image paths turned on" do
|
188
228
|
OpenGraphReader.config.synthesize_image_url = true
|
189
229
|
|
190
|
-
object = OpenGraphReader.parse!
|
230
|
+
object = OpenGraphReader.parse!(
|
231
|
+
fixture_html("real_world/image_path_2"),
|
232
|
+
"http://motherboard.vice.com/de/read/forscher-kreieren-ein-material-das-fast-so-dunkel-ist"\
|
233
|
+
"-wie-ein-schwarzes-loch?trk_source=popular"
|
234
|
+
)
|
191
235
|
|
192
|
-
expect(object.og.type).to
|
193
|
-
expect(object.og.title).to
|
236
|
+
expect(object.og.type).to eq "article"
|
237
|
+
expect(object.og.title).to eq(
|
238
|
+
"Forscher kreieren ein Material, das fast so dunkel ist wie ein schwarzes Loch"
|
239
|
+
)
|
194
240
|
expect(object.og.site_name).to eq "Motherboard"
|
195
|
-
expect(object.og.image.url).to eq
|
196
|
-
|
241
|
+
expect(object.og.image.url).to eq(
|
242
|
+
"https://motherboard-images.vice.com/content-images/article/13701/1405417621515809.JPG?cro"\
|
243
|
+
"p=0.75xw:1xh;*,*&resize=500:*&output-format=jpeg&output-quality=90"
|
244
|
+
)
|
245
|
+
expect(object.og.url).to eq(
|
246
|
+
"http://motherboard.vice.com/de/read/forscher-kreieren-ein-material-das-fast-so-dunkel-ist"\
|
247
|
+
"-wie-ein-schwarzes-loch"
|
248
|
+
)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe "invalid_article_author" do
|
253
|
+
it "does not parse" do
|
254
|
+
expect {
|
255
|
+
OpenGraphReader.parse! fixture_html "real_world/invalid_article_author"
|
256
|
+
}.to raise_error OpenGraphReader::InvalidObjectError, /does not start with/
|
257
|
+
end
|
258
|
+
|
259
|
+
it "ignores the attribute with discarding invalid optional attributes enabled" do
|
260
|
+
OpenGraphReader.config.discard_invalid_optional_properties = true
|
261
|
+
|
262
|
+
object = OpenGraphReader.parse! fixture_html "real_world/invalid_article_author"
|
263
|
+
|
264
|
+
expect(object.article.author).to be_nil
|
265
|
+
expect(object.article.section).to eq "blog/engineering"
|
266
|
+
expect(object.article.published_time).to eq DateTime.iso8601 "2014-12-18T21:16:27+00:00"
|
267
|
+
expect(object.og.site_name).to eq "GitHub"
|
268
|
+
expect(object.og.type).to eq "article"
|
269
|
+
expect(object.og.image.url).to eq "https://github.com/apple-touch-icon-144.png"
|
270
|
+
expect(object.og.title).to eq "Vulnerability announced: update your Git clients"
|
271
|
+
expect(object.og.url).to eq(
|
272
|
+
"https://github.com/blog/1938-vulnerability-announced-update-your-git-clients"
|
273
|
+
)
|
274
|
+
expect(object.og.description).to eq <<-DESCRIPTION.chomp
|
275
|
+
A critical Git security vulnerability has been announced today, affecting all versions of the \
|
276
|
+
official Git client and all related software that interacts with Git repositories, including \
|
277
|
+
GitHub for Windows and GitHub for Mac. Because this is a client-side only vulnerability, \
|
278
|
+
github.com and GitHub Enterprise are not directly affected.
|
279
|
+
|
280
|
+
The vulnerability concerns Git and Git-compatible clients that access Git repositories in a \
|
281
|
+
case-insensitive or case-normalizing filesystem. An attacker can craft a malicious Git tree that \
|
282
|
+
will cause Git to overwrite its own .git/config file when cloning or checking out a repository, \
|
283
|
+
leading to arbitrary command execution in the client machine. Git clients running on OS X (HFS+) \
|
284
|
+
or any version of Microsoft Windows (NTFS, FAT) are exploitable through this vulnerability. Linux \
|
285
|
+
clients are not affected if they run in a case-sensitive filesystem.
|
286
|
+
|
287
|
+
We strongly encourage all users of GitHub and GitHub Enterprise to update their Git clients as \
|
288
|
+
soon as possible, and to be particularly careful when cloning or accessing Git repositories hosted \
|
289
|
+
on unsafe or untrusted hosts.
|
290
|
+
|
291
|
+
Repositories hosted on github.com cannot contain any of the malicious trees that trigger the \
|
292
|
+
vulnerability because we now verify and block these trees on push. We have also completed an \
|
293
|
+
automated scan of all existing content on github.com to look for malicious content that might have \
|
294
|
+
been pushed to our site before this vulnerability was discovered. This work is an extension of the \
|
295
|
+
data-quality checks we have always performed on repositories pushed to our servers to protect our \
|
296
|
+
users against malformed or malicious Git data.
|
297
|
+
|
298
|
+
Updated versions of GitHub for Windows and GitHub for Mac are available for immediate download, and \
|
299
|
+
both contain the security fix on the Desktop application itself and on the bundled version of the \
|
300
|
+
Git command-line client.
|
301
|
+
|
302
|
+
In addition, the following updated versions of Git address this vulnerability:
|
303
|
+
|
304
|
+
|
305
|
+
The Git core team has announced maintenance releases for all current versions of Git (v1.8.5.6, \
|
306
|
+
v1.9.5, v2.0.5, v2.1.4, and v2.2.1).
|
307
|
+
Git for Windows (also known as MSysGit) has released maintenance version 1.9.5.
|
308
|
+
The two major Git libraries, libgit2 and JGit, have released maintenance versions with the fix. \
|
309
|
+
Third party software using these libraries is strongly encouraged to update.
|
310
|
+
|
311
|
+
|
312
|
+
More details on the vulnerability can be found in the official Git mailing list announcement and on \
|
313
|
+
the git-blame blog.
|
314
|
+
DESCRIPTION
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
describe "invalid_datetime" do
|
319
|
+
it "does not parse" do
|
320
|
+
expect {
|
321
|
+
OpenGraphReader.parse! fixture_html "real_world/invalid_datetime"
|
322
|
+
}.to raise_error OpenGraphReader::InvalidObjectError, /ISO8601 datetime expected/
|
323
|
+
end
|
324
|
+
|
325
|
+
it "ignores the attribute with discarding invalid optional attributes enabled" do
|
326
|
+
OpenGraphReader.config.discard_invalid_optional_properties = true
|
327
|
+
|
328
|
+
object = OpenGraphReader.parse! fixture_html "real_world/invalid_datetime"
|
329
|
+
|
330
|
+
expect(object.article.section).to eq "blog/engineering"
|
331
|
+
expect(object.article.published_time).to be_nil
|
332
|
+
expect(object.og.site_name).to eq "GitHub"
|
333
|
+
expect(object.og.type).to eq "article"
|
334
|
+
expect(object.og.image.url).to eq "https://github.com/apple-touch-icon-144.png"
|
335
|
+
expect(object.og.title).to eq "Vulnerability announced: update your Git clients"
|
336
|
+
expect(object.og.url).to eq(
|
337
|
+
"https://github.com/blog/1938-vulnerability-announced-update-your-git-clients"
|
338
|
+
)
|
339
|
+
expect(object.og.description).to eq <<-DESCRIPTION.chomp
|
340
|
+
A critical Git security vulnerability has been announced today, affecting all versions of the \
|
341
|
+
official Git client and all related software that interacts with Git repositories, including \
|
342
|
+
GitHub for Windows and GitHub for Mac. Because this is a client-side only vulnerability, \
|
343
|
+
github.com and GitHub Enterprise are not directly affected.
|
344
|
+
|
345
|
+
The vulnerability concerns Git and Git-compatible clients that access Git repositories in a \
|
346
|
+
case-insensitive or case-normalizing filesystem. An attacker can craft a malicious Git tree that \
|
347
|
+
will cause Git to overwrite its own .git/config file when cloning or checking out a repository, \
|
348
|
+
leading to arbitrary command execution in the client machine. Git clients running on OS X (HFS+) \
|
349
|
+
or any version of Microsoft Windows (NTFS, FAT) are exploitable through this vulnerability. Linux \
|
350
|
+
clients are not affected if they run in a case-sensitive filesystem.
|
351
|
+
|
352
|
+
We strongly encourage all users of GitHub and GitHub Enterprise to update their Git clients as \
|
353
|
+
soon as possible, and to be particularly careful when cloning or accessing Git repositories hosted \
|
354
|
+
on unsafe or untrusted hosts.
|
355
|
+
|
356
|
+
Repositories hosted on github.com cannot contain any of the malicious trees that trigger the \
|
357
|
+
vulnerability because we now verify and block these trees on push. We have also completed an \
|
358
|
+
automated scan of all existing content on github.com to look for malicious content that might have \
|
359
|
+
been pushed to our site before this vulnerability was discovered. This work is an extension of the \
|
360
|
+
data-quality checks we have always performed on repositories pushed to our servers to protect our \
|
361
|
+
users against malformed or malicious Git data.
|
362
|
+
|
363
|
+
Updated versions of GitHub for Windows and GitHub for Mac are available for immediate download, and \
|
364
|
+
both contain the security fix on the Desktop application itself and on the bundled version of the \
|
365
|
+
Git command-line client.
|
366
|
+
|
367
|
+
In addition, the following updated versions of Git address this vulnerability:
|
368
|
+
|
369
|
+
|
370
|
+
The Git core team has announced maintenance releases for all current versions of Git (v1.8.5.6, \
|
371
|
+
v1.9.5, v2.0.5, v2.1.4, and v2.2.1).
|
372
|
+
Git for Windows (also known as MSysGit) has released maintenance version 1.9.5.
|
373
|
+
The two major Git libraries, libgit2 and JGit, have released maintenance versions with the fix. \
|
374
|
+
Third party software using these libraries is strongly encouraged to update.
|
375
|
+
|
376
|
+
|
377
|
+
More details on the vulnerability can be found in the official Git mailing list announcement and on \
|
378
|
+
the git-blame blog.
|
379
|
+
DESCRIPTION
|
380
|
+
end
|
381
|
+
|
382
|
+
it "parses with datetime format parsing turned on" do
|
383
|
+
OpenGraphReader.config.guess_datetime_format = true
|
384
|
+
|
385
|
+
object = OpenGraphReader.parse! fixture_html "real_world/invalid_datetime"
|
386
|
+
|
387
|
+
expect(object.article.section).to eq "blog/engineering"
|
388
|
+
expect(object.article.published_time).to eq DateTime.iso8601 "2014-12-18T21:16:27+00:00"
|
389
|
+
expect(object.og.site_name).to eq "GitHub"
|
390
|
+
expect(object.og.type).to eq "article"
|
391
|
+
expect(object.og.image.url).to eq "https://github.com/apple-touch-icon-144.png"
|
392
|
+
expect(object.og.title).to eq "Vulnerability announced: update your Git clients"
|
393
|
+
expect(object.og.url).to eq "https://github.com/blog/1938-vulnerability-announced-update-your-git-clients"
|
394
|
+
expect(object.og.description).to eq <<-DESCRIPTION.chomp
|
395
|
+
A critical Git security vulnerability has been announced today, affecting all versions of the \
|
396
|
+
official Git client and all related software that interacts with Git repositories, including \
|
397
|
+
GitHub for Windows and GitHub for Mac. Because this is a client-side only vulnerability, \
|
398
|
+
github.com and GitHub Enterprise are not directly affected.
|
399
|
+
|
400
|
+
The vulnerability concerns Git and Git-compatible clients that access Git repositories in a \
|
401
|
+
case-insensitive or case-normalizing filesystem. An attacker can craft a malicious Git tree that \
|
402
|
+
will cause Git to overwrite its own .git/config file when cloning or checking out a repository, \
|
403
|
+
leading to arbitrary command execution in the client machine. Git clients running on OS X (HFS+) \
|
404
|
+
or any version of Microsoft Windows (NTFS, FAT) are exploitable through this vulnerability. Linux \
|
405
|
+
clients are not affected if they run in a case-sensitive filesystem.
|
406
|
+
|
407
|
+
We strongly encourage all users of GitHub and GitHub Enterprise to update their Git clients as \
|
408
|
+
soon as possible, and to be particularly careful when cloning or accessing Git repositories hosted \
|
409
|
+
on unsafe or untrusted hosts.
|
410
|
+
|
411
|
+
Repositories hosted on github.com cannot contain any of the malicious trees that trigger the \
|
412
|
+
vulnerability because we now verify and block these trees on push. We have also completed an \
|
413
|
+
automated scan of all existing content on github.com to look for malicious content that might have \
|
414
|
+
been pushed to our site before this vulnerability was discovered. This work is an extension of the \
|
415
|
+
data-quality checks we have always performed on repositories pushed to our servers to protect our \
|
416
|
+
users against malformed or malicious Git data.
|
417
|
+
|
418
|
+
Updated versions of GitHub for Windows and GitHub for Mac are available for immediate download, and \
|
419
|
+
both contain the security fix on the Desktop application itself and on the bundled version of the \
|
420
|
+
Git command-line client.
|
421
|
+
|
422
|
+
In addition, the following updated versions of Git address this vulnerability:
|
423
|
+
|
424
|
+
|
425
|
+
The Git core team has announced maintenance releases for all current versions of Git (v1.8.5.6, \
|
426
|
+
v1.9.5, v2.0.5, v2.1.4, and v2.2.1).
|
427
|
+
Git for Windows (also known as MSysGit) has released maintenance version 1.9.5.
|
428
|
+
The two major Git libraries, libgit2 and JGit, have released maintenance versions with the fix. \
|
429
|
+
Third party software using these libraries is strongly encouraged to update.
|
430
|
+
|
431
|
+
|
432
|
+
More details on the vulnerability can be found in the official Git mailing list announcement and on \
|
433
|
+
the git-blame blog.
|
434
|
+
DESCRIPTION
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
describe "url_path" do
|
439
|
+
it "does not parse" do
|
440
|
+
expect {
|
441
|
+
OpenGraphReader.parse! fixture_html "real_world/url_path"
|
442
|
+
}.to raise_error OpenGraphReader::InvalidObjectError, /does not start with/
|
443
|
+
end
|
444
|
+
|
445
|
+
it "parses with image paths turned on" do
|
446
|
+
OpenGraphReader.config.synthesize_url = true
|
447
|
+
OpenGraphReader.config.synthesize_image_url = true
|
448
|
+
|
449
|
+
object = OpenGraphReader.parse!(
|
450
|
+
fixture_html("real_world/url_path"),
|
451
|
+
"http://www.nextinpact.com/news/93425-revue-presse-cities-skylines-est-il-simcity-que-on-attendait.htm"
|
452
|
+
)
|
453
|
+
|
454
|
+
expect(object.og.title).to eq "Revue de presse : Cities Skylines est-il le SimCity que l'on attendait ?"
|
455
|
+
expect(object.og.type).to eq "article"
|
456
|
+
expect(object.og.image.url).to eq "https://az664837.vo.msecnd.net/images/bd/wide-linked-media/5920.jpg"
|
457
|
+
expect(object.og.url).to eq(
|
458
|
+
"http://www.nextinpact.com/news/93425-revue-presse-cities-skylines-est-il-simcity-que-on-attendait.htm"
|
459
|
+
)
|
197
460
|
end
|
198
461
|
end
|
199
462
|
end
|