Skip to content

Commit

Permalink
Fix bug where HTML messages could have been rendered empty on some sy…
Browse files Browse the repository at this point in the history
…stems (#5957)

Consistently use $nodeName instead of $tagName property.
  • Loading branch information
alecpl committed Sep 17, 2017
1 parent ee6b5e9 commit 72fe97d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CHANGELOG Roundcube Webmail
- Fix bug where pink image was used instead of a thumbnail when image resize fails (#5933)
- Fix so files size/count limit is verified (client-side) also on drag-n-drop uploads (#5940)
- Fix invalid template loading on a message error in preview frame (#5941)
- Fix bug where HTML messages could have been rendered empty on some systems (#5957)

RELEASE 1.3.1
-------------
Expand Down
16 changes: 8 additions & 8 deletions program/lib/Roundcube/rcube_washtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,17 @@ private function wash_attribs($node)
}
}

if ($this->is_image_attribute($node->tagName, $key)) {
if ($this->is_image_attribute($node->nodeName, $key)) {
$out = $this->wash_uri($value, true);
}
else if ($this->is_link_attribute($node->tagName, $key)) {
else if ($this->is_link_attribute($node->nodeName, $key)) {
if (!preg_match('!^(javascript|vbscript|data:text)!i', $value)
&& preg_match('!^([a-z][a-z0-9.+-]+:|//|#).+!i', $value)
) {
$out = $value;
}
}
else if ($this->is_funciri_attribute($node->tagName, $key)) {
else if ($this->is_funciri_attribute($node->nodeName, $key)) {
if (preg_match('/^[a-z:]*url\(/i', $val)) {
if (preg_match('/^([a-z:]*url)\(\s*[\'"]?([^\'"\)]*)[\'"]?\s*\)/iu', $value, $match)) {
if ($url = $this->wash_uri($match[2])) {
Expand Down Expand Up @@ -454,14 +454,14 @@ private function dumpHtml($node, $level = 20)
do {
switch ($node->nodeType) {
case XML_ELEMENT_NODE: //Check element
$tagName = strtolower($node->tagName);
$tagName = strtolower($node->nodeName);
if ($callback = $this->handlers[$tagName]) {
$dump .= call_user_func($callback, $tagName,
$this->wash_attribs($node), $this->dumpHtml($node, $level), $this);
}
else if (isset($this->_html_elements[$tagName])) {
$content = $this->dumpHtml($node, $level);
$dump .= '<' . $node->tagName;
$dump .= '<' . $node->nodeName;

if ($tagName == 'svg') {
$xpath = new DOMXPath($node->ownerDocument);
Expand All @@ -481,14 +481,14 @@ private function dumpHtml($node, $level = 20)
$dump .= ' />';
}
else {
$dump .= '>' . $content . '</' . $node->tagName . '>';
$dump .= '>' . $content . '</' . $node->nodeName . '>';
}
}
else if (isset($this->_ignore_elements[$tagName])) {
$dump .= '<!-- ' . htmlspecialchars($node->tagName, ENT_QUOTES) . ' not allowed -->';
$dump .= '<!-- ' . htmlspecialchars($node->nodeName, ENT_QUOTES) . ' not allowed -->';
}
else {
$dump .= '<!-- ' . htmlspecialchars($node->tagName, ENT_QUOTES) . ' ignored -->';
$dump .= '<!-- ' . htmlspecialchars($node->nodeName, ENT_QUOTES) . ' ignored -->';
$dump .= $this->dumpHtml($node, $level); // ignore tags not its content
}
break;
Expand Down

0 comments on commit 72fe97d

Please sign in to comment.