diff --git a/src/Html2Text.php b/src/Html2Text.php index 6e0f9e5..dd2154e 100644 --- a/src/Html2Text.php +++ b/src/Html2Text.php @@ -145,7 +145,7 @@ class Html2Text '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // '/<(del)( [^>]*)?>(.*?)<\/del>/i', // '/<(th)( [^>]*)?>(.*?)<\/th>/i', // and - '/<(a) [^>]*href=("|\')([^"\']+)\2([^>]*)>(.*?)<\/a>/i' // + '/<(a) [^>]*href=(?|("|\')([^"\']+)\2|()([^\s"\'>]+))([^>]*)>(.*?)<\/a>/i' // and ); /** diff --git a/test/LinkTest.php b/test/LinkTest.php index 51ab635..5558d36 100644 --- a/test/LinkTest.php +++ b/test/LinkTest.php @@ -181,4 +181,14 @@ public function testMailtoWithEntity() $this->assertEquals($expected, $html2text->getText()); } + + public function testUnquotedHref() + { + $html = 'Link text and other'; + $expected = 'Link text [http://example.com/page?id=1] and other [/example.com]'; + + $html2text = new Html2Text($html, array('do_links' => 'inline')); + + $this->assertEquals($expected, $html2text->getText()); + } }