Skip to content

Commit 7d78d00

Browse files
jcubicmtibben
authored andcommitted
Fix mailto in html entites used on github profile page
1 parent d484bce commit 7d78d00

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Html2Text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ protected function buildlinkList($link, $display, $linkOverride = null)
426426
}
427427

428428
// Ignored link types
429-
if (preg_match('!^(javascript:|mailto:|#)!i', $link)) {
429+
if (preg_match('!^(javascript:|mailto:|#)!i', html_entity_decode($link))) {
430430
return $display;
431431
}
432432

test/LinkTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,24 @@ public function testDoLinksWhenTargetInText()
159159

160160
$this->assertEquals($expected, $html2text->getText());
161161
}
162+
163+
public function testMailto()
164+
{
165+
$html = '<a href="mailto:example@example.com">Link text</a>';
166+
$expected = 'Link text';
167+
168+
$html2text = new Html2Text($html, array('do_links' => 'inline'));
169+
170+
$this->assertEquals($expected, $html2text->getText());
171+
}
172+
173+
public function testMailtoWithEntity()
174+
{
175+
$html = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;example@example.com">Link text</a>';
176+
$expected = 'Link text';
177+
178+
$html2text = new Html2Text($html, array('do_links' => 'inline'));
179+
180+
$this->assertEquals($expected, $html2text->getText());
181+
}
162182
}

0 commit comments

Comments
 (0)