diff --git a/src/markup/__tests__/PhutilMarkupTestCase.php b/src/markup/__tests__/PhutilMarkupTestCase.php index 61f7cba..81301cd 100644 --- a/src/markup/__tests__/PhutilMarkupTestCase.php +++ b/src/markup/__tests__/PhutilMarkupTestCase.php @@ -1,179 +1,179 @@ assertEqual( - phutil_render_tag('x'), - phutil_render_tag('x', array())); + (string)phutil_tag('x'), + (string)phutil_tag('x', array())); $this->assertEqual( - phutil_render_tag('x', array()), - phutil_render_tag('x', array(), null)); + (string)phutil_tag('x', array()), + (string)phutil_tag('x', array(), null)); } public function testTagEmpty() { $this->assertEqual( '', - phutil_render_tag('x', array(), null)); + (string)phutil_tag('x', array(), null)); $this->assertEqual( '', - phutil_render_tag('x', array(), '')); + (string)phutil_tag('x', array(), '')); } public function testTagBasics() { $this->assertEqual( '', - phutil_render_tag('x')); + (string)phutil_tag('x')); $this->assertEqual( 'y', - phutil_render_tag('x', array(), 'y')); + (string)phutil_tag('x', array(), 'y')); } public function testTagAttributes() { $this->assertEqual( 'y', - phutil_render_tag('x', array('u' => 'v'), 'y')); + (string)phutil_tag('x', array('u' => 'v'), 'y')); $this->assertEqual( '', - phutil_render_tag('x', array('u' => 'v'))); + (string)phutil_tag('x', array('u' => 'v'))); } public function testTagEscapes() { $this->assertEqual( '', - phutil_render_tag('x', array('u' => '<'))); + (string)phutil_tag('x', array('u' => '<'))); $this->assertEqual( '', - phutil_render_tag('x', array(), phutil_render_tag('y'))); + (string)phutil_tag('x', array(), phutil_tag('y'))); } public function testTagNullAttribute() { $this->assertEqual( '', - phutil_render_tag('x', array('y' => null))); + (string)phutil_tag('x', array('y' => null))); } public function testTagJavascriptProtocolRejection() { $hrefs = array( 'javascript:alert(1)' => true, 'JAVASCRIPT:alert(1)' => true, ' javascript:alert(1)' => true, '/' => false, '/path/to/stuff/' => false, '' => false, 'http://example.com/' => false, '#' => false, ); foreach (array(true, false) as $use_uri) { foreach ($hrefs as $href => $expect) { if ($use_uri) { $href = new PhutilURI($href); } $caught = null; try { - phutil_render_tag('a', array('href' => $href), 'click for candy'); + phutil_tag('a', array('href' => $href), 'click for candy'); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual( $expect, $caught instanceof Exception, "Rejected href: {$href}"); } } } public function testURIEscape() { $this->assertEqual( '%2B/%20%3F%23%26%3A%21xyz%25', phutil_escape_uri('+/ ?#&:!xyz%')); } public function testURIPathComponentEscape() { $this->assertEqual( 'a%252Fb', phutil_escape_uri_path_component('a/b')); $str = ''; for ($ii = 0; $ii <= 255; $ii++) { $str .= chr($ii); } $this->assertEqual( $str, phutil_unescape_uri_path_component( rawurldecode( // Simulates webserver. phutil_escape_uri_path_component($str)))); } public function testHsprintf() { $this->assertEqual( '
<3
', (string)hsprintf('
%s
', '<3')); } public function testAppendHTML() { $html = phutil_tag('span'); $html->appendHTML(phutil_tag('em'), ''); $this->assertEqual('<evil>', $html->getHTMLContent()); } public function testArrayEscaping() { $this->assertEqual( '
<div>
', phutil_escape_html( array( hsprintf('
'), array( array( '<', array( 'd', array( array( hsprintf('i'), ), 'v', ), ), array( array( '>', ), ), ), ), hsprintf('
'), ))); $this->assertEqual( '
', phutil_tag( 'div', array( ), array( array( array( phutil_tag('x'), array( phutil_tag('y'), ), phutil_tag('z'), ), ), ))->getHTMLContent()); } }