Skip to content

Commit

Permalink
Fix mailto in html entites used on github profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic authored and mtibben committed Apr 16, 2020
1 parent d484bce commit 7d78d00
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Html2Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ protected function buildlinkList($link, $display, $linkOverride = null)
}

// Ignored link types
if (preg_match('!^(javascript:|mailto:|#)!i', $link)) {
if (preg_match('!^(javascript:|mailto:|#)!i', html_entity_decode($link))) {
return $display;
}

Expand Down
20 changes: 20 additions & 0 deletions test/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,24 @@ public function testDoLinksWhenTargetInText()

$this->assertEquals($expected, $html2text->getText());
}

public function testMailto()
{
$html = '<a href="mailto:example@example.com">Link text</a>';
$expected = 'Link text';

$html2text = new Html2Text($html, array('do_links' => 'inline'));

$this->assertEquals($expected, $html2text->getText());
}

public function testMailtoWithEntity()
{
$html = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;example@example.com">Link text</a>';
$expected = 'Link text';

$html2text = new Html2Text($html, array('do_links' => 'inline'));

$this->assertEquals($expected, $html2text->getText());
}
}

0 comments on commit 7d78d00

Please sign in to comment.