Thomas Bruederli
2013-02-05 5bc800f946e39ae0c5afcca79d6ae0af561fc536
Merge branch 'master' of github.com:roundcube/roundcubemail
3 files modified
24 ■■■■ changed files
program/lib/Roundcube/rcube.php 7 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_washtml.php 3 ●●●● patch | view | raw | blame | history
tests/Framework/Washtml.php 14 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube.php
@@ -1073,14 +1073,17 @@
    {
        // handle PHP exceptions
        if (is_object($arg) && is_a($arg, 'Exception')) {
            $err = array(
            $arg = array(
                'type' => 'php',
                'code' => $arg->getCode(),
                'line' => $arg->getLine(),
                'file' => $arg->getFile(),
                'message' => $arg->getMessage(),
            );
            $arg = $err;
        }
        if (empty($arg['code'])) {
            $arg['code'] = 500;
        }
        // installer
program/lib/Roundcube/rcube_washtml.php
@@ -240,7 +240,8 @@
            $value = $node->getAttribute($key);
            if (isset($this->_html_attribs[$key]) ||
                ($key == 'href' && !preg_match('!^(javascript|vbscript|data:text)!i', $value)
                ($key == 'href' && ($value = trim($value))
                    && !preg_match('!^(javascript|vbscript|data:text)!i', $value)
                    && preg_match('!^([a-z][a-z0-9.+-]+:|//|#).+!i', $value))
            ) {
                $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"';
tests/Framework/Washtml.php
@@ -25,4 +25,18 @@
        $this->assertNotRegExp('/vbscript:/', $washed, "Remove vbscript: links");
    }
    /**
     * Test fixing of invalid href (#1488940)
     */
    function test_href()
    {
        $html = "<p><a href=\"\nhttp://test.com\n\">Firefox</a>";
        $washer = new rcube_washtml;
        $washed = $washer->wash($html);
        $this->assertRegExp('|href="http://test.com">|', $washed, "Link href with newlines (#1488940)");
    }
}