Skip to content

Commit

Permalink
Wrapping helper htmlentities calls into AkTextHelper::html_escape
Browse files Browse the repository at this point in the history
AkTextHelper::html_escape (alias AkTextHelper::h )
will use the application charset for escaping entities
  • Loading branch information
bermi committed Jan 5, 2010
1 parent baa90f5 commit 5f3f8ba
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 21 deletions.
Expand Up @@ -179,7 +179,7 @@ public function auto_complete_result($entries, $field, $phrase = null) {
return '';
}
foreach ($entries as $entry) {
$items[] = AkTagHelper::content_tag('li',!empty($phrase) ? AkTextHelper::highlight(AkTextHelper::h($entry[$field]), $phrase) : AkTextHelper::h(@$entry[$field]));
$items[] = AkTagHelper::content_tag('li',!empty($phrase) ? AkTextHelper::highlight(AkTextHelper::html_escape($entry[$field]), $phrase) : AkTextHelper::html_escape(@$entry[$field]));
}
return AkTagHelper::content_tag('ul', join('', array_unique($items)));
}
Expand Down
6 changes: 1 addition & 5 deletions vendor/akelos/action_pack/helpers/ak_tag_helper.php
Expand Up @@ -62,11 +62,7 @@ static function cdata_section($content) {
* # => "1 > 2 & 3"
*/
static function escape_once($html) {
static $charset;
if(empty($charset)){
$charset = Ak::locale('charset');
}
return AkTagHelper::fix_double_escape(htmlentities($html, ENT_COMPAT, $charset));
return AkTagHelper::fix_double_escape(AkTextHelper::html_escape($html));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions vendor/akelos/action_pack/helpers/ak_text_helper.php
Expand Up @@ -650,16 +650,16 @@ static function close_unmatched_html($html) {
return $html;
}

static function html_escape($html) {
static function html_escape($html, $quote_style = ENT_COMPAT) {
static $charset;
if(empty($charset)){
$charset = Ak::locale('charset');
}
return htmlentities($html, ENT_COMPAT, $charset);
return htmlentities($html, $quote_style, $charset);
}

static function h($html) {
return AkTextHelper::html_escape($html);
static function h($html, $quote_style = ENT_COMPAT) {
return AkTextHelper::html_escape($html, $quote_style);
}
}

2 changes: 1 addition & 1 deletion vendor/akelos/action_pack/helpers/ak_url_helper.php
Expand Up @@ -218,7 +218,7 @@ public function mail_to($email_address, $name = null, $html_options = array()) {
$html_options = Ak::delete($html_options, 'cc','bcc','subject','body','encode');

if ($encode == 'javascript'){
$tmp = "document.write('".AkTagHelper::content_tag('a', htmlentities($name, null, Ak::locale('charset')), array_merge($html_options,array('href' => 'mailto:'.$email_address.$extras )))."');";
$tmp = "document.write('".AkTagHelper::content_tag('a', AkTextHelper::html_escape($name, null), array_merge($html_options,array('href' => 'mailto:'.$email_address.$extras )))."');";
for ($i=0; $i < strlen($tmp); $i++){
$string.='%'.dechex(ord($tmp[$i]));
}
Expand Down
6 changes: 3 additions & 3 deletions vendor/akelos/action_pack/helpers/ak_xml_helper.php
Expand Up @@ -47,7 +47,7 @@ public function rss2_builder($items = array(), $channel_options = array(), $item
$return[] = $this->xml_channel_open();
$return[] = $this->xml_title($channel_options['title']);
$return[] = $this->xml_description($channel_options['description']);
$return[] = $this->xml_link(htmlentities($channel_options['link']));
$return[] = $this->xml_link(AkTextHelper::html_escape($channel_options['link']));
$return[] = $this->xml_language($channel_options['language']);
$items = Ak::toArray($items);

Expand Down Expand Up @@ -222,11 +222,11 @@ public function _renderTag($name_space, $tagName, $content = null, $attributes =
foreach($attributes as $name => $value) {
if(is_string($value)) {

$attribute_array[]=$name.'="'.htmlentities($value).'"';
$attribute_array[]=$name.'="'.AkTextHelper::html_escape($value).'"';
} else if (is_array($value)) {
$attr_name_space = $name;
foreach($value as $name => $v) {
$attribute_array[]=$attr_name_space.':'.$name.'="'.htmlentities($v).'"';
$attribute_array[]=$attr_name_space.':'.$name.'="'.AkTextHelper::html_escape($v).'"';
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/akelos/active_support/logger.php
Expand Up @@ -346,7 +346,7 @@ public function handleFileMessage($error_level, $message, $parameters = array())
public function handleDisplayMessage($error_level, $message, $parameters = array()){
if(!empty($this->options['print'])){
list($file,$line,$method) = Ak::getLastFileAndLineAndMethod(false, 3);
Ak::trace("<strong>[$error_level]</strong> - ".AkTextHelper::h($message), $line, $file, $method, false);
Ak::trace("<strong>[$error_level]</strong> - ".AkTextHelper::html_escape($message), $line, $file, $method, false);
if(!empty($parameters)) {
Ak::trace($parameters, $line, $file, $method);
}
Expand Down
Expand Up @@ -46,9 +46,9 @@ public function web_terminal(){
list($response, $last_dir) = explode('----akelos-cmd----', $result);
$_SESSION['last_working_directory'] = trim($last_dir);
if($response){
$this->renderText(AkTextHelper::h($response));
$this->renderText(AkTextHelper::html_escape($response));
}else{
$this->renderText(AkTextHelper::h($this->t('Error or empty response while running: %command', array('%command' => $this->params['cmd']))));
$this->renderText(AkTextHelper::html_escape($this->t('Error or empty response while running: %command', array('%command' => $this->params['cmd']))));
}
}
}else{
Expand Down
Expand Up @@ -18,7 +18,7 @@ function get_menu_option($description, $url, $options = array()){
public function flash_message($type, $message){
return '<div class="flash radius_3 '.$type.'">'.
'<p><span class="icon">'.$this->t(strtoupper($type)).': </span>'.
str_replace("\n", "<br />", AkTextHelper::h($message)).
str_replace("\n", "<br />", AkTextHelper::html_escape($message)).
'</p></div>';
}

Expand Down Expand Up @@ -62,7 +62,7 @@ public function format_snippet($code = '', $snippet_type = ''){

$total = count($lines);
$line_numbers = join("<br />", range(1, $total));
$code = str_replace(array("\n"), array('<br />'), AkTextHelper::h($code));
$code = str_replace(array("\n"), array('<br />'), AkTextHelper::html_escape($code));

$copy_button_version = in_array($snippet_type, array('shell')) ? '-2' : '';

Expand Down
Expand Up @@ -78,7 +78,7 @@ private function _setCodeBlocks($textile){
$css_class = strtolower($class);
$css_class = in_array($css_class, array('shell')) ? 'html' : $css_class;

$escaped = AkTextHelper::h($matches[2][$k]);
$escaped = AkTextHelper::html_escape($matches[2][$k]);
$textile = str_replace($matches[0][$k], $this->_tabText("<notextile><div class='code_container'><code class='$css_class'>$escaped</code></div></notextile>"), $textile);
}
}
Expand Down
Expand Up @@ -60,7 +60,7 @@ private function _setCodeBlocks($textile){
foreach ($matches[1] as $k => $class){
$css_class = strtolower($class);
$css_class = in_array($css_class, array('shell')) ? 'html' : $css_class;
$escaped = AkTextHelper::h($matches[2][$k]);
$escaped = AkTextHelper::html_escape($matches[2][$k]);
$textile = str_replace($matches[0][$k], $this->_tabText("<notextile><div class='code_container'><code class='$css_class'>$escaped</code></div></notextile>"), $textile);
}
}
Expand Down

0 comments on commit 5f3f8ba

Please sign in to comment.