/** * Tests the escaper * * @author Nikos Dimopoulos <*****@*****.**> * @since 2012-11-30 */ public function testEscapeHtml() { $escaper = new PhEscaper(); $source = "<h1></h1>"; $expected = '<h1></h1>'; $actual = $escaper->escapeHtml($source); $this->assertEquals($expected, $actual, 'The escaper does not escape string correctly'); }
public function register() { $escaper = new Escaper(); $escaper->setEncoding('utf-8'); return $escaper; }
/** * Returns scripts to be inserted before <head> * Since setBaseUri may or may not end in a /, double slashes are removed. * * @return string */ public function getInsertScripts() { $escaper = new Escaper(); $url = $this->getDI()->get('url'); $scripts = ""; $css = array('/pdw-assets/style.css', '/pdw-assets/lib/prism/prism.css'); foreach ($css as $src) { $link = $url->get($src); $link = str_replace("//", "/", $link); $scripts .= "<link rel='stylesheet' type='text/css' href='" . $escaper->escapeHtmlAttr($link) . "' />"; } $js = array('/pdw-assets/jquery.min.js', '/pdw-assets/lib/prism/prism.js', '/pdw-assets/pdw.js'); foreach ($js as $src) { $link = $url->get($src); $link = str_replace("//", "/", $link); $scripts .= "<script tyle='text/javascript' src='" . $escaper->escapeHtmlAttr($link) . "'></script>"; } return $scripts; }
public function escapeUrl($url) { return parent::escapeUrl($url); }
private function includeJquery() { $escaper = new Escaper(); $html = Tag::javascriptInclude("//code.jquery.com/jquery-1.11.1.min.js", false); $html .= "\n<script>window.jQuery || document.write('" . trim($escaper->escapeJs(Tag::javascriptInclude('js/jquery-1.11.1.min.js'))) . "');</script>"; return $html; }