From 6d5308a2116826b45b37ca6e71e3e5b99333c3d5 Mon Sep 17 00:00:00 2001 From: Stefan Schramm Date: Wed, 28 Sep 2022 10:49:47 +0200 Subject: [PATCH] Prevent self-closing tag syntax --- README.md | 50 ++++++++++++++--------------- src/SEOTools/OpenGraph.php | 2 +- src/SEOTools/SEOMeta.php | 16 ++++----- src/SEOTools/TwitterCards.php | 2 +- tests/SEOTools/OpenGraphTest.php | 6 ++-- tests/SEOTools/SEOMetaTest.php | 10 +++--- tests/SEOTools/SEOToolsTest.php | 32 +++++++++--------- tests/SEOTools/TwitterCardsTest.php | 18 +++++------ 8 files changed, 68 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 9819fc9..22d6608 100644 --- a/README.md +++ b/README.md @@ -253,7 +253,7 @@ class CommomController extends Controller OpenGraph::addImage($post->images->list('url')); OpenGraph::addImage(['url' => 'http://image.url.com/cover.jpg', 'size' => 300]); OpenGraph::addImage('http://image.url.com/cover.jpg', ['height' => 300, 'width' => 300]); - + JsonLd::setTitle($post->title); JsonLd::setDescription($post->resume); JsonLd::setType('Article'); @@ -485,30 +485,30 @@ class CommomController extends Controller Title - Over 9000 Thousand! - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SEOTools/OpenGraph.php b/src/SEOTools/OpenGraph.php index 25dc745..dd5ac4d 100644 --- a/src/SEOTools/OpenGraph.php +++ b/src/SEOTools/OpenGraph.php @@ -264,7 +264,7 @@ protected function eachProperties( protected function makeTag($key = null, $value = null, $ogPrefix = false) { return sprintf( - '%s', + '%s', $ogPrefix ? $this->og_prefix : '', strip_tags($key), $this->cleanTagValue($value), diff --git a/src/SEOTools/SEOMeta.php b/src/SEOTools/SEOMeta.php index 362fabe..f73b0bf 100644 --- a/src/SEOTools/SEOMeta.php +++ b/src/SEOTools/SEOMeta.php @@ -160,11 +160,11 @@ public function generate($minify = false) } if (!empty($keywords)) { - + if($keywords instanceof \Illuminate\Support\Collection){ $keywords = $keywords->toArray(); } - + $keywords = implode(', ', $keywords); $html[] = ""; } @@ -182,23 +182,23 @@ public function generate($minify = false) } if ($canonical) { - $html[] = ""; + $html[] = ""; } if ($amphtml) { - $html[] = ""; + $html[] = ""; } if ($prev) { - $html[] = ""; + $html[] = ""; } if ($next) { - $html[] = ""; + $html[] = ""; } foreach ($languages as $lang) { - $html[] = ""; + $html[] = ""; } if ($robots) { @@ -215,7 +215,7 @@ public function setTitle($title, $appendDefault = true) { // open redirect vulnerability fix $title = str_replace(['http-equiv=', 'url='], '', $title); - + // clean title $title = strip_tags($title); diff --git a/src/SEOTools/TwitterCards.php b/src/SEOTools/TwitterCards.php index 8eac452..388c774 100644 --- a/src/SEOTools/TwitterCards.php +++ b/src/SEOTools/TwitterCards.php @@ -84,7 +84,7 @@ protected function eachValue(array $values, $prefix = null) private function makeTag($key, $value) { return sprintf( - '', + '', $this->prefix.strip_tags($key), $this->cleanTagValue($value) ); diff --git a/tests/SEOTools/OpenGraphTest.php b/tests/SEOTools/OpenGraphTest.php index eb1dc58..f57f3a4 100644 --- a/tests/SEOTools/OpenGraphTest.php +++ b/tests/SEOTools/OpenGraphTest.php @@ -29,7 +29,7 @@ public function test_set_title_and_description() $this->openGraphs->setTitle('Hello, Ali'); $this->openGraphs->setDescription('This is a test by Ali.'); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); @@ -39,7 +39,7 @@ public function test_set_url() { $this->openGraphs->setUrl('https://www.domain.com'); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); @@ -54,7 +54,7 @@ public function test_can_generate_tags_from_array() "tag" => $tags, ]); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); } diff --git a/tests/SEOTools/SEOMetaTest.php b/tests/SEOTools/SEOMetaTest.php index 51cc6d2..eb96108 100644 --- a/tests/SEOTools/SEOMetaTest.php +++ b/tests/SEOTools/SEOMetaTest.php @@ -159,7 +159,7 @@ public function test_set_canonical() { $fullHeader = "It's Over 9000!"; $fullHeader .= ""; - $fullHeader .= ""; + $fullHeader .= ""; $canonical = 'http://domain.com'; $this->seoMeta->setCanonical($canonical); @@ -216,7 +216,7 @@ public function test_set_amp() { $fullHeader = "It's Over 9000!"; $fullHeader .= ""; - $fullHeader .= ""; + $fullHeader .= ""; $amphtml = 'http://domain.com/amp'; $this->seoMeta->setAmpHtml($amphtml); @@ -229,7 +229,7 @@ public function test_set_next() { $fullHeader = "It's Over 9000!"; $fullHeader .= ""; - $fullHeader .= ""; + $fullHeader .= ""; $next = 'http://domain.com'; $this->seoMeta->setNext($next); @@ -242,7 +242,7 @@ public function test_set_prev() { $fullHeader = "It's Over 9000!"; $fullHeader .= ""; - $fullHeader .= ""; + $fullHeader .= ""; $prev = 'http://domain.com'; $this->seoMeta->setPrev($prev); @@ -255,7 +255,7 @@ public function test_set_alternate_languages() { $fullHeader = "It's Over 9000!"; $fullHeader .= ""; - $fullHeader .= ""; + $fullHeader .= ""; $lang = 'en'; $langUrl = 'http://domain.com'; diff --git a/tests/SEOTools/SEOToolsTest.php b/tests/SEOTools/SEOToolsTest.php index fb952bc..5b6093f 100644 --- a/tests/SEOTools/SEOToolsTest.php +++ b/tests/SEOTools/SEOToolsTest.php @@ -48,9 +48,9 @@ public function test_set_title() $expected = "Kamehamehaaaaaaa - It's Over 9000!"; $expected .= ''; - $expected .= ''; - $expected .= ''; - $expected .= ''; + $expected .= ''; + $expected .= ''; + $expected .= ''; $expected .= ''; $this->assertEquals('Kamehamehaaaaaaa - It\'s Over 9000!', $this->seoTools->getTitle()); @@ -63,9 +63,9 @@ public function test_set_description() $expected = "It's Over 9000!"; $expected .= ''; - $expected .= ''; - $expected .= ''; - $expected .= ''; + $expected .= ''; + $expected .= ''; + $expected .= ''; $expected .= ''; @@ -78,9 +78,9 @@ public function test_set_canonical() $expected = "It's Over 9000!"; $expected .= ''; - $expected .= ''; - $expected .= ''; - $expected .= ''; + $expected .= ''; + $expected .= ''; + $expected .= ''; $expected .= ''; $this->setRightAssertion($expected); @@ -93,11 +93,11 @@ public function test_add_images() $expected = "It's Over 9000!"; $expected .= ''; - $expected .= ''; - $expected .= ''; - $expected .= ''; - $expected .= ''; - $expected .= ''; + $expected .= ''; + $expected .= ''; + $expected .= ''; + $expected .= ''; + $expected .= ''; $expected .= ''; $this->setRightAssertion($expected); @@ -107,8 +107,8 @@ public function test_generate() { $expected = "It's Over 9000!"; $expected .= ''; - $expected .= ''; - $expected .= ''; + $expected .= ''; + $expected .= ''; $expected .= ''; $this->setRightAssertion($expected); diff --git a/tests/SEOTools/TwitterCardsTest.php b/tests/SEOTools/TwitterCardsTest.php index a71d983..e66eb9f 100644 --- a/tests/SEOTools/TwitterCardsTest.php +++ b/tests/SEOTools/TwitterCardsTest.php @@ -28,7 +28,7 @@ public function test_set_title() { $this->twitterCards->setTitle('Kamehamehaaaaaaaa'); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); } @@ -37,7 +37,7 @@ public function test_set_site() { $this->twitterCards->setSite('http://kakaroto.9000'); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); } @@ -46,7 +46,7 @@ public function test_set_url() { $this->twitterCards->setUrl('http://kakaroto.9000'); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); } @@ -55,7 +55,7 @@ public function test_set_description() { $this->twitterCards->setDescription('Kamehamehaaaaaaaa'); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); } @@ -66,7 +66,7 @@ public function test_cleans_description() $this->twitterCards->setDescription($description); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); } @@ -75,7 +75,7 @@ public function test_set_type() { $this->twitterCards->setType('sayajin'); - $expected = ''; + $expected = ''; $this->setRightAssertion($expected); } @@ -84,8 +84,8 @@ public function test_set_images() { $this->twitterCards->setImages(['sayajin.png', 'namekusei.png']); - $expected = ""; - $expected .= ""; + $expected = ""; + $expected .= ""; $this->setRightAssertion($expected); } @@ -94,7 +94,7 @@ public function test_set_image() { $this->twitterCards->setImage('sayajin.png'); - $expected = ""; + $expected = ""; $this->setRightAssertion($expected); }