Skip to content

Commit 36b12e8

Browse files
Fix schema org protocol (#161)
* Update meta.py Change http://schema.org to https://schema.org * Add changes file and fix schema.org protocol in tests --------- Co-authored-by: Stefan van den Eertwegh <[email protected]>
1 parent 17e4fb9 commit 36b12e8

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

changes/152.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix schema.org protocol to be https

meta/templatetags/meta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def schemaorg_html_scope(value):
178178
179179
:param value: declared scope
180180
"""
181-
return ' itemscope itemtype="http://schema.org/%s" ' % escape(value)
181+
return ' itemscope itemtype="https://schema.org/%s" ' % escape(value)
182182

183183

184184
@register.simple_tag
@@ -255,7 +255,7 @@ def meta_namespaces_schemaorg(context):
255255
# do nothing if meta is not in context or if G+ is not enabled
256256
if not context.get("meta") or not context["meta"].use_schemaorg:
257257
return ""
258-
return mark_safe(' itemscope itemtype="http://schema.org/{}" '.format(context["meta"].schemaorg_type))
258+
return mark_safe(' itemscope itemtype="https://schema.org/{}" '.format(context["meta"].schemaorg_type))
259259

260260

261261
@register.simple_tag(takes_context=True)

tests/test_mixin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ def test_as_meta_get_request_deprecation(self):
175175
def test_templatetag(self):
176176
self.post.as_meta()
177177
response = self.client.get("/title/")
178-
self.assertContains(response, '<html itemscope itemtype="http://schema.org/Article" >')
179-
self.assertNotContains(response, ' itemscope itemtype="http://schema.org/Article"')
178+
self.assertContains(response, '<html itemscope itemtype="https://schema.org/Article" >')
179+
self.assertNotContains(response, ' itemscope itemtype="https://schema.org/Article"')
180180
self.assertContains(response, 'article:published_time"')
181181
self.assertContains(
182182
response, '<meta name="twitter:image" content="http://example.com{}">'.format(self.image_url)
@@ -297,7 +297,7 @@ def test_google_plus_scope_works(self):
297297
"""
298298
Test vendorized googleplus_scope templatetag
299299
"""
300-
self.assertEqual(googleplus_html_scope("bar"), ' itemscope itemtype="http://schema.org/bar" ')
300+
self.assertEqual(googleplus_html_scope("bar"), ' itemscope itemtype="https://schema.org/bar" ')
301301

302302
@override_settings(META_SITE_PROTOCOL="https")
303303
def test_image_protocol(self):

tests/test_templatetags.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ def test_google_plus_basically_works(self):
137137
def test_google_plus_html_scope_works(self):
138138
with warnings.catch_warnings(record=True) as w:
139139
warnings.simplefilter("always")
140-
self.assertEqual(googleplus_html_scope("bar"), ' itemscope itemtype="http://schema.org/bar" ')
140+
self.assertEqual(googleplus_html_scope("bar"), ' itemscope itemtype="https://schema.org/bar" ')
141141
assert len(w) == 1
142142
assert issubclass(w[-1].category, PendingDeprecationWarning)
143143

144144
def test_google_plus_scope_works(self):
145145
with warnings.catch_warnings(record=True) as w:
146146
warnings.simplefilter("always")
147-
self.assertEqual(googleplus_scope("bar"), ' itemscope itemtype="http://schema.org/bar" ')
147+
self.assertEqual(googleplus_scope("bar"), ' itemscope itemtype="https://schema.org/bar" ')
148148
assert len(w) == 1
149149
assert issubclass(w[-1].category, PendingDeprecationWarning)
150150

@@ -174,7 +174,7 @@ def test_meta_namespaces_gplus(self):
174174
with warnings.catch_warnings(record=True) as w:
175175
warnings.simplefilter("always")
176176
self.assertEqual(
177-
meta_namespaces_gplus(context_use_schemaorg), ' itemscope itemtype="http://schema.org/Article" '
177+
meta_namespaces_gplus(context_use_schemaorg), ' itemscope itemtype="https://schema.org/Article" '
178178
)
179179
assert len(w) == 1
180180
assert issubclass(w[-1].category, PendingDeprecationWarning)
@@ -185,10 +185,10 @@ def test_schemaorg_basically_works(self):
185185
self.assertEqual(schemaorg_prop("foo", "bar"), '<meta itemprop="foo" content="bar">')
186186

187187
def test_schemaorg_html_scope_works(self):
188-
self.assertEqual(schemaorg_html_scope("bar"), ' itemscope itemtype="http://schema.org/bar" ')
188+
self.assertEqual(schemaorg_html_scope("bar"), ' itemscope itemtype="https://schema.org/bar" ')
189189

190190
def test_schemaorg_scope_works(self):
191-
self.assertEqual(schemaorg_scope("bar"), ' itemscope itemtype="http://schema.org/bar" ')
191+
self.assertEqual(schemaorg_scope("bar"), ' itemscope itemtype="https://schema.org/bar" ')
192192

193193
def test_schemaorg_escapes_xss(self):
194194
self.assertEqual(schemaorg_prop('fo"o', "b<ar"), '<meta itemprop="fo&quot;o" content="b&lt;ar">')
@@ -202,7 +202,7 @@ def test_meta_namespaces_gplus(self):
202202
self.assertEqual(meta_namespaces_schemaorg(context_no_use_schemaorg), "")
203203

204204
self.assertEqual(
205-
meta_namespaces_schemaorg(context_use_schemaorg), ' itemscope itemtype="http://schema.org/Article" '
205+
meta_namespaces_schemaorg(context_use_schemaorg), ' itemscope itemtype="https://schema.org/Article" '
206206
)
207207

208208

0 commit comments

Comments
 (0)