Beispiel #1
1
 public function getRowData()
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers('Escaping');
     $routing = sfContext::getInstance()->getRouting();
     $measure = array('direct rating' => 'Direct Measure', 'direct float' => 'Direct (float)');
     $measure = array_merge($measure, sfConfig::get('app_rating_method'));
     $measure = array_merge($measure, array('comment' => 'Comment'));
     return array('_element_type' => 'criterion', 'id' => $this->id, 'name' => $this->name, 'description' => esc_raw($this->description), 'type' => $this->variable_type, 'measure' => $measure[$this->measurement], 'fetch_url' => $routing->generate('criterion\\fetch', array('id' => $this->id)), 'edit_url' => $routing->generate('criterion\\edit', array('id' => $this->id)), 'delete_url' => $routing->generate('criterion\\delete'));
 }
require_once(dirname(__FILE__).'/../../../lib/helper/EscapingHelper.php');

$t = new lime_test(11);

sfConfig::set('sf_charset', 'UTF-8');

// esc_entities()
$t->diag('esc_entities()');
$t->is(esc_entities(10), 10, 'esc_entities() does not escape integers');
$t->is(esc_entities(false), false, 'esc_entities() does not escape booleans');
$t->is(esc_entities('foo bar'), 'foo bar', 'esc_entities() only escapes strings');
$t->is(esc_entities('<b>foo</b> bar'), '&lt;b&gt;foo&lt;/b&gt; bar', 'esc_entities() only escapes strings');

// esc_raw()
$t->diag('esc_raw()');
$t->is(esc_raw('foo'), 'foo', 'esc_raw() returns the first argument as is');

// esc_js()
$t->diag('esc_js()');
$t->is(esc_js('alert(\'foo\' + "bar")'), 'alert(&#039;foo&#039; + &quot;bar&quot;)', 'esc_js() escapes javascripts');

// esc_js_no_entities()
$t->diag('esc_js_no_entities()');
$t->is(esc_js_no_entities('alert(\'foo\' + "bar")'), 'alert(\\\'foo\\\' + \\"bar\\")', 'esc_js_no_entities() escapes javascripts');
$t->is(esc_js_no_entities('alert("hi\\there")'), 'alert(\\"hi\\\\there\\")', 'esc_js_no_entities() handles slashes correctly');
$t->is(esc_js_no_entities('alert("été")'), 'alert(\\"été\\")', 'esc_js_no_entities() preserves utf-8');
$output = <<<EOF
alert('hello
world')
EOF;
$t->is(esc_js_no_entities(fix_linebreaks($output)), 'alert(\\\'hello\\nworld\\\')', 'esc_js_no_entities() handles linebreaks correctly');
Beispiel #3
0
 public function getRowData()
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers('Escaping');
     $routing = sfContext::getInstance()->getRouting();
     $updated_at = new DateTime($this->updated_at);
     return array('_element_type' => 'role', 'id' => $this->id, 'name' => $this->name, 'description' => esc_raw($this->comment), 'responses_count' => count($this->getResponse()), 'dashboard' => $this->dashboard, 'active' => $this->active, 'updated_at' => $updated_at->format('M, j H:i'), 'url' => sfContext::getInstance()->getConfiguration()->generateFrontendUrl('measure', array('token' => $this->token)), 'fetch_url' => $routing->generate('role\\fetch', array('id' => $this->id)), 'edit_url' => $routing->generate('role\\edit', array('id' => $this->id)), 'delete_url' => $routing->generate('role\\delete'));
 }
 public static function esc_raw($content)
 {
     return esc_raw($content);
 }
<?php

/**
 * @var array $params
 */
if (isset($params['help'])) {
    use_helper('Markdown');
    echo '<div class="description parameter">' . esc_raw(Markdown($params['help'])) . '</div>';
}