mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge pull request #1739 from nickvergessen/ticket/11871
[ticket/11871] Allow backslash in classnames for Modules
This commit is contained in:
commit
fdae60c146
3 changed files with 29 additions and 11 deletions
|
@ -565,7 +565,7 @@ class acp_modules
|
||||||
{
|
{
|
||||||
// Skip entries we do not need if we know the module we are
|
// Skip entries we do not need if we know the module we are
|
||||||
// looking for
|
// looking for
|
||||||
if ($module && strpos(str_replace('\\', '_', $cur_module), $module) === false)
|
if ($module && strpos(str_replace('\\', '_', $cur_module), $module) === false && $module !== $cur_module)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,7 +519,7 @@ class p_master
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not being able to overwrite ;)
|
// Not being able to overwrite ;)
|
||||||
$this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
|
$this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=' . $this->get_module_identifier($this->p_name, $this->p_id)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -551,7 +551,7 @@ class p_master
|
||||||
$this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'];
|
$this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
|
$this->module->u_action = append_sid($this->module->u_action, 'i=' . $this->get_module_identifier($this->p_name, $this->p_id)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add url_extra parameter to u_action url
|
// Add url_extra parameter to u_action url
|
||||||
|
@ -799,12 +799,12 @@ class p_master
|
||||||
// if the item has a name use it, else use its id
|
// if the item has a name use it, else use its id
|
||||||
if (empty($item_ary['name']))
|
if (empty($item_ary['name']))
|
||||||
{
|
{
|
||||||
$u_title .= $item_ary['id'];
|
$u_title .= $item_ary['id'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if the category has a name, then use it.
|
// if the category has a name, then use it.
|
||||||
$u_title .= $item_ary['name'];
|
$u_title .= $this->get_module_identifier($item_ary['name'], $item_ary['id']);
|
||||||
}
|
}
|
||||||
// If the item is not a category append the mode
|
// If the item is not a category append the mode
|
||||||
if (!$item_ary['cat'])
|
if (!$item_ary['cat'])
|
||||||
|
@ -982,6 +982,29 @@ class p_master
|
||||||
return substr($basename, strlen($this->p_class) + 1);
|
return substr($basename, strlen($this->p_class) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the basename contains a \ we dont use that for the URL.
|
||||||
|
*
|
||||||
|
* Firefox is currently unable to correctly copy a urlencoded \
|
||||||
|
* so users will be unable to post links to modules.
|
||||||
|
* However we can still fallback to the id instead of the name,
|
||||||
|
* so we do that in this case.
|
||||||
|
*
|
||||||
|
* @param string $basename Basename of the module
|
||||||
|
* @param int $id Id of the module
|
||||||
|
* @return mixed Identifier that should be used for
|
||||||
|
* module link creation
|
||||||
|
*/
|
||||||
|
protected function get_module_identifier($basename, $id)
|
||||||
|
{
|
||||||
|
if (strpos($basename, '\\') === false)
|
||||||
|
{
|
||||||
|
return $basename;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the given module basename is a correct class name
|
* Checks whether the given module basename is a correct class name
|
||||||
*
|
*
|
||||||
|
|
|
@ -182,9 +182,6 @@ class module implements \phpbb\db\migration\tool\tool_interface
|
||||||
{
|
{
|
||||||
// The "automatic" way
|
// The "automatic" way
|
||||||
$basename = (isset($data['module_basename'])) ? $data['module_basename'] : '';
|
$basename = (isset($data['module_basename'])) ? $data['module_basename'] : '';
|
||||||
$basename = str_replace(array('/', '\\'), '', $basename);
|
|
||||||
$class = str_replace(array('/', '\\'), '', $class);
|
|
||||||
|
|
||||||
$module = $this->get_module_info($class, $basename);
|
$module = $this->get_module_info($class, $basename);
|
||||||
|
|
||||||
$result = '';
|
$result = '';
|
||||||
|
@ -353,9 +350,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatic method
|
// Automatic method
|
||||||
$basename = str_replace(array('/', '\\'), '', $module['module_basename']);
|
$basename = $module['module_basename'];
|
||||||
$class = str_replace(array('/', '\\'), '', $class);
|
|
||||||
|
|
||||||
$module_info = $this->get_module_info($class, $basename);
|
$module_info = $this->get_module_info($class, $basename);
|
||||||
|
|
||||||
foreach ($module_info['modes'] as $mode => $info)
|
foreach ($module_info['modes'] as $mode => $info)
|
||||||
|
|
Loading…
Add table
Reference in a new issue