From 1810274c8a1f080d878d948b126116549346b9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Rish=C3=B8j?= Date: Thu, 14 Sep 2017 11:42:34 +0700 Subject: [PATCH] escape HTML entities in `src`-attribute --- src/HtmlBuilder.php | 2 +- tests/HtmlBuilderTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index d2ba3cd..fa6f319 100755 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -162,7 +162,7 @@ class HtmlBuilder $title = $this->entities($title); } - return $this->toHtmlString('attributes($attributes) . '>' . $title . ''); + return $this->toHtmlString('attributes($attributes) . '>' . $title . ''); } /** diff --git a/tests/HtmlBuilderTest.php b/tests/HtmlBuilderTest.php index b5d7d99..9a4d486 100644 --- a/tests/HtmlBuilderTest.php +++ b/tests/HtmlBuilderTest.php @@ -118,8 +118,11 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase $result2 = $this->htmlBuilder->link("http://www.example.com", "Example.com", ["class" => "example-link"], null, false); + $result3 = $this->htmlBuilder->link("https://a.com/b?id=4¬_id=5", "URL which needs escaping"); + $this->assertEquals('<span>Example.com</span>', $result1); $this->assertEquals('Example.com', $result2); + $this->assertEquals('URL which needs escaping', $result3); } public function testMailto()