diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-11-08 14:06:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-08 14:06:38 +0100 |
commit | 8d8fa898ab09da87d6c5b333ce6c5b7e8d1506d0 (patch) | |
tree | 123066f497546ad181c96ef2bdd1fde011457807 /tests/bookmark/LinkUtilsTest.php | |
parent | 8c5f6c786d00310b2e863aa316927effb7bfeedb (diff) | |
parent | 00d3dd91ef42df13eeafbcc54dcebe3238e322c6 (diff) | |
download | Shaarli-8d8fa898ab09da87d6c5b333ce6c5b7e8d1506d0.tar.gz Shaarli-8d8fa898ab09da87d6c5b333ce6c5b7e8d1506d0.tar.zst Shaarli-8d8fa898ab09da87d6c5b333ce6c5b7e8d1506d0.zip |
Merge pull request #1631 from ArthurHoaro/fix/html-extract-quote-fix
Fix an issue truncating extracted metadata content
Diffstat (limited to 'tests/bookmark/LinkUtilsTest.php')
-rw-r--r-- | tests/bookmark/LinkUtilsTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php index 3321242f..9bddf84b 100644 --- a/tests/bookmark/LinkUtilsTest.php +++ b/tests/bookmark/LinkUtilsTest.php | |||
@@ -169,6 +169,36 @@ class LinkUtilsTest extends TestCase | |||
169 | } | 169 | } |
170 | 170 | ||
171 | /** | 171 | /** |
172 | * Test html_extract_tag() with double quoted content containing single quote, and the opposite. | ||
173 | */ | ||
174 | public function testHtmlExtractExistentNameTagWithMixedQuotes(): void | ||
175 | { | ||
176 | $description = 'Bob and Alice share M&M\'s.'; | ||
177 | |||
178 | $html = '<meta property="og:description" content="' . $description . '">'; | ||
179 | $this->assertEquals($description, html_extract_tag('description', $html)); | ||
180 | |||
181 | $html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" '. | ||
182 | 'tag2="content2" content="' . $description . '" tag3="content3">'; | ||
183 | $this->assertEquals($description, html_extract_tag('description', $html)); | ||
184 | |||
185 | $html = '<meta property="og:description" name="description" content="' . $description . '">'; | ||
186 | $this->assertEquals($description, html_extract_tag('description', $html)); | ||
187 | |||
188 | $description = 'Bob and Alice share "cookies".'; | ||
189 | |||
190 | $html = '<meta property="og:description" content=\'' . $description . '\'>'; | ||
191 | $this->assertEquals($description, html_extract_tag('description', $html)); | ||
192 | |||
193 | $html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" '. | ||
194 | 'tag2="content2" content=\'' . $description . '\' tag3="content3">'; | ||
195 | $this->assertEquals($description, html_extract_tag('description', $html)); | ||
196 | |||
197 | $html = '<meta property="og:description" name="description" content=\'' . $description . '\'>'; | ||
198 | $this->assertEquals($description, html_extract_tag('description', $html)); | ||
199 | } | ||
200 | |||
201 | /** | ||
172 | * Test html_extract_tag() when the tag <meta name= is not found. | 202 | * Test html_extract_tag() when the tag <meta name= is not found. |
173 | */ | 203 | */ |
174 | public function testHtmlExtractNonExistentNameTag() | 204 | public function testHtmlExtractNonExistentNameTag() |