load_gui(); $RCMAIL->action = 'autocomplete'; $RCMAIL->storage_init(false); require_once INSTALL_PATH . 'program/steps/mail/func.inc'; } /** * Helper method to create a HTML message part object */ function get_html_part($body = null) { $part = new rcube_message_part; $part->ctype_primary = 'text'; $part->ctype_secondary = 'html'; $part->body = $body ? file_get_contents(TESTS_DIR . $body) : null; $part->replaces = array(); return $part; } /** * Test sanitization of a "normal" html message */ function test_html() { $part = $this->get_html_part('src/htmlbody.txt'); $part->replaces = array('ex1.jpg' => 'part_1.2.jpg', 'ex2.jpg' => 'part_1.2.jpg'); $params = array('container_id' => 'foo'); // render HTML in normal mode $html = rcmail_html4inline(rcmail_print_body($part->body, $part, array('safe' => false)), $params); $this->assertRegExp('/src="'.$part->replaces['ex1.jpg'].'"/', $html, "Replace reference to inline image"); $this->assertRegExp('#background="program/resources/blocked.gif"#', $html, "Replace external background image"); $this->assertNotRegExp('/ex3.jpg/', $html, "No references to external images"); $this->assertNotRegExp('/]+>/', $html, "No meta tags allowed"); $this->assertNotRegExp('/