Browse Source

Fix anchor links in HTML mail (#8632)

pull/8646/head
Aleksander Machniak 3 years ago
parent
commit
5c4e18820e
  1. 1
      CHANGELOG.md
  2. 7
      program/lib/Roundcube/rcube_washtml.php
  3. 7
      tests/Framework/Washtml.php

1
CHANGELOG.md

@ -5,6 +5,7 @@
- Advanced mail search syntax with more possibilities (without UI) (#8502)
- Fix various PHP 8.1 warnings (#8628)
- Password: Remove references to %c variable that has been removed before (#8633)
- Fix anchor links in HTML mail (#8632)
## Release 1.6.0

7
program/lib/Roundcube/rcube_washtml.php

@ -359,7 +359,9 @@ class rcube_washtml
$out = $value;
}
}
else if ($this->_css_prefix !== null && in_array($key, ['id', 'class', 'for'])) {
else if ($this->_css_prefix !== null
&& (in_array($key, ['id', 'class', 'for']) || ($key == 'name' && $node->nodeName == 'a'))
) {
$out = preg_replace('/(\S+)/', $this->_css_prefix . '\1', $value);
}
else if ($key) {
@ -367,7 +369,8 @@ class rcube_washtml
}
if ($out !== null && $out !== '') {
$result .= ' ' . $attr->nodeName . '="' . htmlspecialchars($out, ENT_QUOTES | ENT_SUBSTITUTE, $this->config['charset']) . '"';
$v = htmlspecialchars($out, ENT_QUOTES | ENT_SUBSTITUTE, $this->config['charset']);
$result .= " {$attr->nodeName}=\"{$v}\"";
}
else if ($value) {
$washed[] = htmlspecialchars($attr->nodeName, ENT_QUOTES, $this->config['charset']);

7
tests/Framework/Washtml.php

@ -664,6 +664,13 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
$this->assertStringContainsString('for="testmy-other-id"', $washed);
$this->assertStringContainsString('href="#testmy-id"', $washed);
$this->assertStringContainsString('class="testmy-class1 testmy-class2"', $washed);
// Make sure the anchor name is prefixed too
$html = '<p><a href="#a">test link</a></p><a name="a">test anchor</a>';
$washed = $washer->wash($html);
$this->assertStringContainsString('href="#testa"', $washed);
$this->assertStringContainsString('name="testa"', $washed);
}
/**

Loading…
Cancel
Save