- Fix relative URLs handling according to a <base> in HTML (#1487889)
1 files added
4 files modified
| | |
| | | CHANGELOG Roundcube Webmail |
| | | =========================== |
| | | |
| | | - Fix relative URLs handling according to a <base> in HTML (#1487889) |
| | | - Fix handling of top-level domains with more than 5 chars or unicode chars (#1487883) |
| | | - Fix usage of non-standard HTTP error codes (#1487797) |
| | | - Improve performance by including files with absolute path (#1487849) |
| | |
| | | } |
| | | |
| | | // $path is absolute |
| | | if ($path{0}=='/') |
| | | if ($path[0] == '/') |
| | | $abs_path = $host_url.$path; |
| | | else |
| | | { |
| | |
| | | { |
| | | if (strrpos($base_url, '/')) |
| | | $base_url = substr($base_url, 0, strrpos($base_url, '/')); |
| | | |
| | | |
| | | $path = substr($path, 3); |
| | | } |
| | | |
| | | $abs_path = $base_url.'/'.$path; |
| | | } |
| | | |
| | | |
| | | return $abs_path; |
| | | } |
| | | |
| | |
| | | $html = '<head></head>'. $html; |
| | | $html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '<head>')+6), 0); |
| | | } |
| | | |
| | | // turn relative into absolute urls |
| | | $html = rcmail_resolve_base($html); |
| | | |
| | |
| | | function rcmail_message_full_headers($attrib, $headers=NULL) |
| | | { |
| | | global $OUTPUT; |
| | | |
| | | |
| | | $html = html::div(array('class' => "more-headers show-headers", 'onclick' => "return ".JS_OBJECT_NAME.".command('load-headers','',this)"), ''); |
| | | $html .= html::div(array('id' => "all-headers", 'class' => "all", 'style' => 'display:none'), html::div(array('id' => 'headers-source'), '')); |
| | | |
| | | |
| | | $OUTPUT->add_gui_object('all_headers_row', 'all-headers'); |
| | | $OUTPUT->add_gui_object('all_headers_box', 'headers-source'); |
| | | |
| | | |
| | | return html::div($attrib, $html); |
| | | } |
| | | |
| | |
| | | $replacer = new rcube_base_replacer($regs[2]); |
| | | |
| | | // replace all relative paths |
| | | $body = preg_replace_callback('/(src|background|href)=(["\']?)([\.\/]+[^"\'\s]+)(\2|\s|>)/Ui', array($replacer, 'callback'), $body); |
| | | $body = preg_replace_callback('/(url\s*\()(["\']?)([\.\/]+[^"\'\)\s]+)(\2)\)/Ui', array($replacer, 'callback'), $body); |
| | | $body = preg_replace_callback('/(src|background|href)=(["\']?)([^"\'\s]+)(\2|\s|>)/Ui', array($replacer, 'callback'), $body); |
| | | $body = preg_replace_callback('/(url\s*\()(["\']?)([^"\'\)\s]+)(\2)\)/Ui', array($replacer, 'callback'), $body); |
| | | } |
| | | |
| | | return $body; |
| | |
| | | $this->assertNoPattern('|<p>test2</p>|', $washed, "Conditional HTML comments"); |
| | | } |
| | | |
| | | /** |
| | | * Test URI base resolving in HTML messages |
| | | */ |
| | | function test_resolve_base() |
| | | { |
| | | $html = file_get_contents(TESTS_DIR . 'src/htmlbase.txt'); |
| | | $html = rcmail_resolve_base($html); |
| | | |
| | | $this->assertPattern('|src="http://alec\.pl/dir/img1\.gif"|', $html, "URI base resolving [1]"); |
| | | $this->assertPattern('|src="http://alec\.pl/dir/img2\.gif"|', $html, "URI base resolving [2]"); |
| | | $this->assertPattern('|src="http://alec\.pl/img3\.gif"|', $html, "URI base resolving [3]"); |
| | | } |
| | | } |
New file |
| | |
| | | <html> |
| | | <head> |
| | | <base href="http://alec.pl/dir/" /> |
| | | </head> |
| | | <body> |
| | | <img src="img1.gif" /> |
| | | <img src="./img2.gif" /> |
| | | <img src="../img3.gif" /> |
| | | </body> |
| | | </html> |