Skip to content

Commit 0c5e723

Browse files
authored
Prevent self-closing tag syntax (#287)
1 parent 117fa25 commit 0c5e723

File tree

8 files changed

+68
-68
lines changed

8 files changed

+68
-68
lines changed

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class CommomController extends Controller
253253
OpenGraph::addImage($post->images->list('url'));
254254
OpenGraph::addImage(['url' => 'http://image.url.com/cover.jpg', 'size' => 300]);
255255
OpenGraph::addImage('http://image.url.com/cover.jpg', ['height' => 300, 'width' => 300]);
256-
256+
257257
JsonLd::setTitle($post->title);
258258
JsonLd::setDescription($post->resume);
259259
JsonLd::setType('Article');
@@ -485,30 +485,30 @@ class CommomController extends Controller
485485
<html>
486486
<head>
487487
<title>Title - Over 9000 Thousand!</title>
488-
<meta name='description' itemprop='description' content='description...' />
489-
<meta name='keywords' content='key1, key2, key3' />
490-
<meta property='article:published_time' content='2015-01-31T20:30:11-02:00' />
491-
<meta property='article:section' content='news' />
492-
493-
<meta property="og:description"content="description..." />
494-
<meta property="og:title"content="Title" />
495-
<meta property="og:url"content="http://current.url.com" />
496-
<meta property="og:type"content="article" />
497-
<meta property="og:locale"content="pt-br" />
498-
<meta property="og:locale:alternate"content="pt-pt" />
499-
<meta property="og:locale:alternate"content="en-us" />
500-
<meta property="og:site_name"content="name" />
501-
<meta property="og:image"content="http://image.url.com/cover.jpg" />
502-
<meta property="og:image"content="http://image.url.com/img1.jpg" />
503-
<meta property="og:image"content="http://image.url.com/img2.jpg" />
504-
<meta property="og:image"content="http://image.url.com/img3.jpg" />
505-
<meta property="og:image:url"content="http://image.url.com/cover.jpg" />
506-
<meta property="og:image:size"content="300" />
507-
508-
<meta name="twitter:card"content="summary" />
509-
<meta name="twitter:title"content="Title" />
510-
<meta name="twitter:site"content="@LuizVinicius73" />
511-
488+
<meta name='description' itemprop='description' content='description...'>
489+
<meta name='keywords' content='key1, key2, key3'>
490+
<meta property='article:published_time' content='2015-01-31T20:30:11-02:00'>
491+
<meta property='article:section' content='news'>
492+
493+
<meta property="og:description" content="description...">
494+
<meta property="og:title" content="Title">
495+
<meta property="og:url" content="http://current.url.com">
496+
<meta property="og:type" content="article">
497+
<meta property="og:locale" content="pt-br">
498+
<meta property="og:locale:alternate" content="pt-pt">
499+
<meta property="og:locale:alternate" content="en-us">
500+
<meta property="og:site_name" content="name">
501+
<meta property="og:image" content="http://image.url.com/cover.jpg">
502+
<meta property="og:image" content="http://image.url.com/img1.jpg">
503+
<meta property="og:image" content="http://image.url.com/img2.jpg">
504+
<meta property="og:image" content="http://image.url.com/img3.jpg">
505+
<meta property="og:image:url" content="http://image.url.com/cover.jpg">
506+
<meta property="og:image:size" content="300">
507+
508+
<meta name="twitter:card"content="summary">
509+
<meta name="twitter:title"content="Title">
510+
<meta name="twitter:site"content="@LuizVinicius73">
511+
512512
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","name":"Title - Over 9000 Thousand!"}</script>
513513
<!-- OR with multi -->
514514
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","name":"Title - Over 9000 Thousand!"}</script>

src/SEOTools/OpenGraph.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ protected function eachProperties(
264264
protected function makeTag($key = null, $value = null, $ogPrefix = false)
265265
{
266266
return sprintf(
267-
'<meta property="%s%s" content="%s" />%s',
267+
'<meta property="%s%s" content="%s">%s',
268268
$ogPrefix ? $this->og_prefix : '',
269269
strip_tags($key),
270270
$this->cleanTagValue($value),

src/SEOTools/SEOMeta.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ public function generate($minify = false)
160160
}
161161

162162
if (!empty($keywords)) {
163-
163+
164164
if($keywords instanceof \Illuminate\Support\Collection){
165165
$keywords = $keywords->toArray();
166166
}
167-
167+
168168
$keywords = implode(', ', $keywords);
169169
$html[] = "<meta name=\"keywords\" content=\"{$keywords}\">";
170170
}
@@ -182,23 +182,23 @@ public function generate($minify = false)
182182
}
183183

184184
if ($canonical) {
185-
$html[] = "<link rel=\"canonical\" href=\"{$canonical}\"/>";
185+
$html[] = "<link rel=\"canonical\" href=\"{$canonical}\">";
186186
}
187187

188188
if ($amphtml) {
189-
$html[] = "<link rel=\"amphtml\" href=\"{$amphtml}\"/>";
189+
$html[] = "<link rel=\"amphtml\" href=\"{$amphtml}\">";
190190
}
191191

192192
if ($prev) {
193-
$html[] = "<link rel=\"prev\" href=\"{$prev}\"/>";
193+
$html[] = "<link rel=\"prev\" href=\"{$prev}\">";
194194
}
195195

196196
if ($next) {
197-
$html[] = "<link rel=\"next\" href=\"{$next}\"/>";
197+
$html[] = "<link rel=\"next\" href=\"{$next}\">";
198198
}
199199

200200
foreach ($languages as $lang) {
201-
$html[] = "<link rel=\"alternate\" hreflang=\"{$lang['lang']}\" href=\"{$lang['url']}\"/>";
201+
$html[] = "<link rel=\"alternate\" hreflang=\"{$lang['lang']}\" href=\"{$lang['url']}\">";
202202
}
203203

204204
if ($robots) {
@@ -215,7 +215,7 @@ public function setTitle($title, $appendDefault = true)
215215
{
216216
// open redirect vulnerability fix
217217
$title = str_replace(['http-equiv=', 'url='], '', $title);
218-
218+
219219
// clean title
220220
$title = strip_tags($title);
221221

src/SEOTools/TwitterCards.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function eachValue(array $values, $prefix = null)
8484
private function makeTag($key, $value)
8585
{
8686
return sprintf(
87-
'<meta name="%s" content="%s" />',
87+
'<meta name="%s" content="%s">',
8888
$this->prefix.strip_tags($key),
8989
$this->cleanTagValue($value)
9090
);

tests/SEOTools/OpenGraphTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function test_set_title_and_description()
2929
$this->openGraphs->setTitle('Hello, Ali');
3030
$this->openGraphs->setDescription('This is a test by Ali.');
3131

32-
$expected = '<meta property="og:title" content="Hello, Ali" /><meta property="og:description" content="This is a test by Ali." />';
32+
$expected = '<meta property="og:title" content="Hello, Ali"><meta property="og:description" content="This is a test by Ali.">';
3333

3434
$this->setRightAssertion($expected);
3535

@@ -39,7 +39,7 @@ public function test_set_url()
3939
{
4040
$this->openGraphs->setUrl('https://www.domain.com');
4141

42-
$expected = '<meta property="og:title" content="Over 9000 Thousand!" /><meta property="og:description" content="For those who helped create the Genki Dama" /><meta content="https://www.domain.com" property="og:url">';
42+
$expected = '<meta property="og:title" content="Over 9000 Thousand!"><meta property="og:description" content="For those who helped create the Genki Dama"><meta content="https://www.domain.com" property="og:url">';
4343

4444
$this->setRightAssertion($expected);
4545

@@ -54,7 +54,7 @@ public function test_can_generate_tags_from_array()
5454
"tag" => $tags,
5555
]);
5656

57-
$expected = '<meta content="article" property="og:type"><meta property="og:title" content="Over 9000 Thousand!" /><meta property="og:description" content="For those who helped create the Genki Dama" /><meta property="article:tag" content="Example" /><meta property="article:tag" content="tags" /><meta property="article:tag" content="test" />';
57+
$expected = '<meta content="article" property="og:type"><meta property="og:title" content="Over 9000 Thousand!"><meta property="og:description" content="For those who helped create the Genki Dama"><meta property="article:tag" content="Example"><meta property="article:tag" content="tags"><meta property="article:tag" content="test">';
5858

5959
$this->setRightAssertion($expected);
6060
}

tests/SEOTools/SEOMetaTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function test_set_canonical()
159159
{
160160
$fullHeader = "<title>It's Over 9000!</title>";
161161
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
162-
$fullHeader .= "<link rel=\"canonical\" href=\"http://domain.com\"/>";
162+
$fullHeader .= "<link rel=\"canonical\" href=\"http://domain.com\">";
163163
$canonical = 'http://domain.com';
164164

165165
$this->seoMeta->setCanonical($canonical);
@@ -216,7 +216,7 @@ public function test_set_amp()
216216
{
217217
$fullHeader = "<title>It's Over 9000!</title>";
218218
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
219-
$fullHeader .= "<link rel=\"amphtml\" href=\"http://domain.com/amp\"/>";
219+
$fullHeader .= "<link rel=\"amphtml\" href=\"http://domain.com/amp\">";
220220
$amphtml = 'http://domain.com/amp';
221221

222222
$this->seoMeta->setAmpHtml($amphtml);
@@ -229,7 +229,7 @@ public function test_set_next()
229229
{
230230
$fullHeader = "<title>It's Over 9000!</title>";
231231
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
232-
$fullHeader .= "<link rel=\"next\" href=\"http://domain.com\"/>";
232+
$fullHeader .= "<link rel=\"next\" href=\"http://domain.com\">";
233233
$next = 'http://domain.com';
234234

235235
$this->seoMeta->setNext($next);
@@ -242,7 +242,7 @@ public function test_set_prev()
242242
{
243243
$fullHeader = "<title>It's Over 9000!</title>";
244244
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
245-
$fullHeader .= "<link rel=\"prev\" href=\"http://domain.com\"/>";
245+
$fullHeader .= "<link rel=\"prev\" href=\"http://domain.com\">";
246246
$prev = 'http://domain.com';
247247

248248
$this->seoMeta->setPrev($prev);
@@ -255,7 +255,7 @@ public function test_set_alternate_languages()
255255
{
256256
$fullHeader = "<title>It's Over 9000!</title>";
257257
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
258-
$fullHeader .= "<link rel=\"alternate\" hreflang=\"en\" href=\"http://domain.com\"/>";
258+
$fullHeader .= "<link rel=\"alternate\" hreflang=\"en\" href=\"http://domain.com\">";
259259
$lang = 'en';
260260
$langUrl = 'http://domain.com';
261261

tests/SEOTools/SEOToolsTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public function test_set_title()
4848

4949
$expected = "<title>Kamehamehaaaaaaa - It's Over 9000!</title>";
5050
$expected .= '<meta name="description" content="For those who helped create the Genki Dama">';
51-
$expected .= '<meta property="og:title" content="Kamehamehaaaaaaa" />';
52-
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama" />';
53-
$expected .= '<meta name="twitter:title" content="Kamehamehaaaaaaa" />';
51+
$expected .= '<meta property="og:title" content="Kamehamehaaaaaaa">';
52+
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama">';
53+
$expected .= '<meta name="twitter:title" content="Kamehamehaaaaaaa">';
5454
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Kamehamehaaaaaaa","description":"For those who helped create the Genki Dama"}</script>';
5555

5656
$this->assertEquals('Kamehamehaaaaaaa - It\'s Over 9000!', $this->seoTools->getTitle());
@@ -63,9 +63,9 @@ public function test_set_description()
6363

6464
$expected = "<title>It's Over 9000!</title>";
6565
$expected .= '<meta name="description" content="Kamehamehaaaaaaa">';
66-
$expected .= '<meta property="og:description" content="Kamehamehaaaaaaa" />';
67-
$expected .= '<meta property="og:title" content="Over 9000 Thousand!" />';
68-
$expected .= '<meta name="twitter:description" content="Kamehamehaaaaaaa" />';
66+
$expected .= '<meta property="og:description" content="Kamehamehaaaaaaa">';
67+
$expected .= '<meta property="og:title" content="Over 9000 Thousand!">';
68+
$expected .= '<meta name="twitter:description" content="Kamehamehaaaaaaa">';
6969
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Over 9000 Thousand!","description":"Kamehamehaaaaaaa"}</script>';
7070

7171

@@ -78,9 +78,9 @@ public function test_set_canonical()
7878

7979
$expected = "<title>It's Over 9000!</title>";
8080
$expected .= '<meta name="description" content="For those who helped create the Genki Dama">';
81-
$expected .= '<link rel="canonical" href="http://domain.com"/>';
82-
$expected .= '<meta property="og:title" content="Over 9000 Thousand!" />';
83-
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama" />';
81+
$expected .= '<link rel="canonical" href="http://domain.com">';
82+
$expected .= '<meta property="og:title" content="Over 9000 Thousand!">';
83+
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama">';
8484
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Over 9000 Thousand!","description":"For those who helped create the Genki Dama"}</script>';
8585

8686
$this->setRightAssertion($expected);
@@ -93,11 +93,11 @@ public function test_add_images()
9393

9494
$expected = "<title>It's Over 9000!</title>";
9595
$expected .= '<meta name="description" content="For those who helped create the Genki Dama">';
96-
$expected .= '<meta property="og:title" content="Over 9000 Thousand!" />';
97-
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama" />';
98-
$expected .= '<meta property="og:image" content="Kamehamehaaaaaaa.png" />';
99-
$expected .= '<meta property="og:image" content="Kamehamehaaaaaaa.png" />';
100-
$expected .= '<meta name="twitter:image" content="Kamehamehaaaaaaa.png" />';
96+
$expected .= '<meta property="og:title" content="Over 9000 Thousand!">';
97+
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama">';
98+
$expected .= '<meta property="og:image" content="Kamehamehaaaaaaa.png">';
99+
$expected .= '<meta property="og:image" content="Kamehamehaaaaaaa.png">';
100+
$expected .= '<meta name="twitter:image" content="Kamehamehaaaaaaa.png">';
101101
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Over 9000 Thousand!","description":"For those who helped create the Genki Dama","image":["Kamehamehaaaaaaa.png","Kamehamehaaaaaaa.png"]}</script>';
102102

103103
$this->setRightAssertion($expected);
@@ -107,8 +107,8 @@ public function test_generate()
107107
{
108108
$expected = "<title>It's Over 9000!</title>";
109109
$expected .= '<meta name="description" content="For those who helped create the Genki Dama">';
110-
$expected .= '<meta property="og:title" content="Over 9000 Thousand!" />';
111-
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama" />';
110+
$expected .= '<meta property="og:title" content="Over 9000 Thousand!">';
111+
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama">';
112112
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Over 9000 Thousand!","description":"For those who helped create the Genki Dama"}</script>';
113113

114114
$this->setRightAssertion($expected);

tests/SEOTools/TwitterCardsTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function test_set_title()
2828
{
2929
$this->twitterCards->setTitle('Kamehamehaaaaaaaa');
3030

31-
$expected = '<meta name="twitter:title" content="Kamehamehaaaaaaaa" />';
31+
$expected = '<meta name="twitter:title" content="Kamehamehaaaaaaaa">';
3232

3333
$this->setRightAssertion($expected);
3434
}
@@ -37,7 +37,7 @@ public function test_set_site()
3737
{
3838
$this->twitterCards->setSite('http://kakaroto.9000');
3939

40-
$expected = '<meta name="twitter:site" content="http://kakaroto.9000" />';
40+
$expected = '<meta name="twitter:site" content="http://kakaroto.9000">';
4141

4242
$this->setRightAssertion($expected);
4343
}
@@ -46,7 +46,7 @@ public function test_set_url()
4646
{
4747
$this->twitterCards->setUrl('http://kakaroto.9000');
4848

49-
$expected = '<meta name="twitter:url" content="http://kakaroto.9000" />';
49+
$expected = '<meta name="twitter:url" content="http://kakaroto.9000">';
5050

5151
$this->setRightAssertion($expected);
5252
}
@@ -55,7 +55,7 @@ public function test_set_description()
5555
{
5656
$this->twitterCards->setDescription('Kamehamehaaaaaaaa');
5757

58-
$expected = '<meta name="twitter:description" content="Kamehamehaaaaaaaa" />';
58+
$expected = '<meta name="twitter:description" content="Kamehamehaaaaaaaa">';
5959

6060
$this->setRightAssertion($expected);
6161
}
@@ -66,7 +66,7 @@ public function test_cleans_description()
6666

6767
$this->twitterCards->setDescription($description);
6868

69-
$expected = '<meta name="twitter:description" content="&quot;Foo bar&quot; -&gt; abc" />';
69+
$expected = '<meta name="twitter:description" content="&quot;Foo bar&quot; -&gt; abc">';
7070

7171
$this->setRightAssertion($expected);
7272
}
@@ -75,7 +75,7 @@ public function test_set_type()
7575
{
7676
$this->twitterCards->setType('sayajin');
7777

78-
$expected = '<meta name="twitter:card" content="sayajin" />';
78+
$expected = '<meta name="twitter:card" content="sayajin">';
7979

8080
$this->setRightAssertion($expected);
8181
}
@@ -84,8 +84,8 @@ public function test_set_images()
8484
{
8585
$this->twitterCards->setImages(['sayajin.png', 'namekusei.png']);
8686

87-
$expected = "<meta name=\"twitter:images0\" content=\"sayajin.png\" />";
88-
$expected .= "<meta name=\"twitter:images1\" content=\"namekusei.png\" />";
87+
$expected = "<meta name=\"twitter:images0\" content=\"sayajin.png\">";
88+
$expected .= "<meta name=\"twitter:images1\" content=\"namekusei.png\">";
8989

9090
$this->setRightAssertion($expected);
9191
}
@@ -94,7 +94,7 @@ public function test_set_image()
9494
{
9595
$this->twitterCards->setImage('sayajin.png');
9696

97-
$expected = "<meta name=\"twitter:image\" content=\"sayajin.png\" />";
97+
$expected = "<meta name=\"twitter:image\" content=\"sayajin.png\">";
9898

9999
$this->setRightAssertion($expected);
100100
}

0 commit comments

Comments
 (0)