Skip to content
Permalink
Browse files

Sanitise the plugin category so that it can be used as an html id att…

…ribute value
  • Loading branch information...
bramley committed Jun 9, 2019
1 parent 1ee0e60 commit 141d860dceb3536d998d4a2009bb6e63907e66b6
Showing with 17 additions and 2 deletions.
  1. +1 −1 public_html/lists/admin/configure.php
  2. +15 −0 public_html/lists/admin/lib.php
  3. +1 −1 public_html/lists/admin/plugins.php
@@ -131,7 +131,7 @@
foreach ($configCategories as $configCategory => $configItems) {
$some = 0;
$categoryHTML = '<fieldset id="' . $configCategory . '">';
$categoryHTML = '<fieldset id="' . sanitiseId($configCategory) . '">';
$categoryHTML .= '<legend>' . s('%s settings',$configCategory) . '</legend>';
foreach ($configItems as $configItem) {
@@ -2310,3 +2310,18 @@ function asyncLoadContentDiv($url,$divname)
asyncLoadUrl[asyncLoadUrl.length] = "'.$url.'";
</script>';
}
/**
* Transform a value to be valid for an html id by removing invalid characters.
* This is for HTML 4. HTML 5 is more lenient.
*
* @see https://www.w3.org/TR/html4/types.html#type-id
*
* @param string $value
*
* @return string
*/
function sanitiseId($value)
{
return preg_replace('/[^0-9A-Za-z\-_:.]/', '', $value);
}
@@ -294,7 +294,7 @@
if ($plugin->enabled && !empty($plugin->settings)) {
$firstSetting = reset($plugin->settings);
$category = $firstSetting['category'];
$settingsUrl = PageURL2('configure').'#'.strtolower($category);
$settingsUrl = PageURL2('configure').'#'.sanitiseId(strtolower($category));
$detailEntry .= '<span class="label">'.s('Configure').'</span>';
$detailEntry .= '<span class="value"><a href="'.$settingsUrl.'">'.s($category).' '.s('settings').'</a></span>';
}

0 comments on commit 141d860

Please sign in to comment.
You can’t perform that action at this time.