From a39fd4db67cbebc9aecb906818f578608c9180fc Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 1 Feb 2013 15:19:49 +0100 Subject: Set default error code (500) if not specified in raise_error() --- program/lib/Roundcube/rcube.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'program') diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index a914ae65a..3ae511e1e 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -1073,14 +1073,17 @@ class rcube { // 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 -- cgit v1.2.3 From 1f910cb50dcb12e84d92db4d61dcd8dbb0f0c5b6 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 1 Feb 2013 20:04:00 +0100 Subject: Fix handling link href attribute value with (valid) newline characters (#1488940) --- program/lib/Roundcube/rcube_washtml.php | 3 ++- tests/Framework/Washtml.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'program') diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php index 715c46047..2a261419f 100644 --- a/program/lib/Roundcube/rcube_washtml.php +++ b/program/lib/Roundcube/rcube_washtml.php @@ -240,7 +240,8 @@ class rcube_washtml $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) . '"'; diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php index 088ac4a8c..6f4aa9783 100644 --- a/tests/Framework/Washtml.php +++ b/tests/Framework/Washtml.php @@ -25,4 +25,18 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase $this->assertNotRegExp('/vbscript:/', $washed, "Remove vbscript: links"); } + /** + * Test fixing of invalid href (#1488940) + */ + function test_href() + { + $html = "

Firefox"; + + $washer = new rcube_washtml; + + $washed = $washer->wash($html); + + $this->assertRegExp('|href="http://test.com">|', $washed, "Link href with newlines (#1488940)"); + } + } -- cgit v1.2.3