Skip to content

Commit

Permalink
Fix bug where HTML entities in URLs were not decoded on HTML to plain…
Browse files Browse the repository at this point in the history
… text conversion (#9312)
  • Loading branch information
alecpl committed Jan 27, 2024
1 parent cadc82e commit 549f99c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Makefile: Use phpDocumentor v3.4 for the Framework docs (#9313)
- Fix bug where HTML entities in URLs were not decoded on HTML to plain text conversion (#9312)

## Release 1.6.6

Expand Down
1 change: 1 addition & 0 deletions program/lib/Roundcube/rcube_html2text.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ public function tags_preg_callback($matches)
case 'a':
// Remove spaces in URL (#1487805)
$url = str_replace(' ', '', $matches[3]);
$url = html_entity_decode($url, \ENT_HTML5, RCUBE_CHARSET);
return $this->_handle_link($url, $matches[4]);
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/Framework/Html2text.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ function test_links()
$res = $ht->get_text();

$this->assertSame($expected, $res, 'Skip link with href == content');

// HTML entities in links
$html = '<a href="http://test.com?test1&amp;test2">test3&amp;test4</a>';
$expected = 'test3&test4 [1]
Links:
------
[1] http://test.com?test1&test2
';

$ht = new rcube_html2text($html, false, rcube_html2text::LINKS_END);
$res = $ht->get_text();

$this->assertSame($expected, $res, 'Links with HTML entities');
}

/**
Expand Down

0 comments on commit 549f99c

Please sign in to comment.