Commit 9794b553 authored by Steven Wittens's avatar Steven Wittens

- #55898: Generic, permissive admin XSS/HTML filtering for mission/footer/...

- Clean up some raw output
parent 77dc67ec
......@@ -244,8 +244,8 @@ function drupal_goto($path = '', $query = NULL, $fragment = NULL) {
function drupal_site_offline() {
drupal_set_header('HTTP/1.0 503 Service unavailable');
drupal_set_title(t('Site off-line'));
print theme('maintenance_page', variable_get('site_offline_message',
t('%site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('%site' => variable_get('site_name', t('This Drupal site'))))));
print theme('maintenance_page', filter_xss_admin(variable_get('site_offline_message',
t('%site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('%site' => variable_get('site_name', t('This Drupal site')))))));
}
/**
......
......@@ -430,7 +430,7 @@ function contact_mail_page() {
if (count($categories) > 0) {
$form['#token'] = $user->name . $user->mail;
$form['contact_information'] = array('#value' => variable_get('contact_form_information', t('You can leave us a message using the contact form below.')));
$form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.'))));
$form['name'] = array('#type' => 'textfield',
'#title' => t('Your name'),
'#maxlength' => 255,
......
......@@ -430,7 +430,7 @@ function contact_mail_page() {
if (count($categories) > 0) {
$form['#token'] = $user->name . $user->mail;
$form['contact_information'] = array('#value' => variable_get('contact_form_information', t('You can leave us a message using the contact form below.')));
$form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.'))));
$form['name'] = array('#type' => 'textfield',
'#title' => t('Your name'),
'#maxlength' => 255,
......
......@@ -1097,6 +1097,20 @@ function _filter_autop($text) {
return $output;
}
/**
* Very permissive XSS/HTML filter for admin-only use.
*
* Use only for fields where it is impractical to use the
* whole filter system, but where some (mainly inline) mark-up
* is desired (so check_plain() is not acceptable).
*
* Allows all tags that can be used inside an HTML body, save
* for scripts and styles.
*/
function filter_xss_admin($string) {
return filter_xss($string, array('a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'h', 'h', 'h', 'h', 'h', 'h', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'object', 'ol', 'p', 'param', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var'));
}
/**
* Filters XSS. Based on kses by Ulf Harnhammar, see
* http://sourceforge.net/projects/kses
......
......@@ -1097,6 +1097,20 @@ function _filter_autop($text) {
return $output;
}
/**
* Very permissive XSS/HTML filter for admin-only use.
*
* Use only for fields where it is impractical to use the
* whole filter system, but where some (mainly inline) mark-up
* is desired (so check_plain() is not acceptable).
*
* Allows all tags that can be used inside an HTML body, save
* for scripts and styles.
*/
function filter_xss_admin($string) {
return filter_xss($string, array('a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'h', 'h', 'h', 'h', 'h', 'h', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'object', 'ol', 'p', 'param', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var'));
}
/**
* Filters XSS. Based on kses by Ulf Harnhammar, see
* http://sourceforge.net/projects/kses
......
......@@ -935,7 +935,7 @@ function theme_forum_list($forums, $parents, $tid) {
$description .= ' <div class="name">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
if ($forum->description) {
$description .= ' <div class="description">'. check_plain($forum->description) ."</div>\n";
$description .= ' <div class="description">'. filter_xss_admin($forum->description) ."</div>\n";
}
$description .= "</div>\n";
......@@ -952,7 +952,7 @@ function theme_forum_list($forums, $parents, $tid) {
$description .= ' <div class="name">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
if ($forum->description) {
$description .= ' <div class="description">'. check_plain($forum->description) ."</div>\n";
$description .= ' <div class="description">'. filter_xss_admin($forum->description) ."</div>\n";
}
$description .= "</div>\n";
......
......@@ -935,7 +935,7 @@ function theme_forum_list($forums, $parents, $tid) {
$description .= ' <div class="name">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
if ($forum->description) {
$description .= ' <div class="description">'. check_plain($forum->description) ."</div>\n";
$description .= ' <div class="description">'. filter_xss_admin($forum->description) ."</div>\n";
}
$description .= "</div>\n";
......@@ -952,7 +952,7 @@ function theme_forum_list($forums, $parents, $tid) {
$description .= ' <div class="name">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
if ($forum->description) {
$description .= ' <div class="description">'. check_plain($forum->description) ."</div>\n";
$description .= ' <div class="description">'. filter_xss_admin($forum->description) ."</div>\n";
}
$description .= "</div>\n";
......
......@@ -48,7 +48,7 @@ function node_help($section) {
}
if (arg(0) == 'node' && arg(1) == 'add' && $type = arg(2)) {
return variable_get($type .'_help', '');
return filter_xss_admin(variable_get($type .'_help', ''));
}
}
......
......@@ -48,7 +48,7 @@ function node_help($section) {
}
if (arg(0) == 'node' && arg(1) == 'add' && $type = arg(2)) {
return variable_get($type .'_help', '');
return filter_xss_admin(variable_get($type .'_help', ''));
}
}
......
......@@ -29,7 +29,7 @@ function taxonomy_link($type, $node = NULL) {
$links = array();
if (array_key_exists('taxonomy', $node)) {
foreach ($node->taxonomy as $term) {
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => $term->description));
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
}
}
return $links;
......
......@@ -29,7 +29,7 @@ function taxonomy_link($type, $node = NULL) {
$links = array();
if (array_key_exists('taxonomy', $node)) {
foreach ($node->taxonomy as $term) {
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => $term->description));
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
}
}
return $links;
......
......@@ -143,7 +143,7 @@ function phptemplate_page($content) {
/* Set title and breadcrumb to declared values */
if (drupal_get_path_alias($_GET['q']) == variable_get('site_frontpage', 'node')) {
$mission = filter_xss(theme_get_setting('mission'));
$mission = filter_xss_admin(theme_get_setting('mission'));
}
/* Add favicon */
......@@ -188,7 +188,7 @@ function phptemplate_page($content) {
'breadcrumb' => theme('breadcrumb', drupal_get_breadcrumb()),
'closure' => theme('closure'),
'content' => '<!-- begin content -->' . $content . '<!-- end content -->',
'footer_message' => variable_get('site_footer', FALSE) . "\n" . theme('blocks', 'footer'),
'footer_message' => filter_xss_admin(variable_get('site_footer', FALSE)) . "\n" . theme('blocks', 'footer'),
'head' => drupal_get_html_head(),
'head_title' => implode(' | ', $head_title),
'help' => theme('help'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment