I am currently working on a MVC Style framework for a company and for security reasons I need to make sure that the controller / method that passed through the query string are valid characters in the RFC (which I cannot find).
I need to be able to check / sanitize class names according to what is allowed by the PHP interpreter
Example:
class SomEFunk__YClAssName extends Controller
{
}
I need some kind of regular expression that will check SomEFunk__YClAssNameand sanitize it if necessary! These are also the same principles as methods.
There are several things to consider, for example
- Numbering at the beginning
- Only underscores allowed
- Certain special PHP characters allowed.
.
Router Code, , :
private function prepareQueryString()
{
if(strlen($this->query_string) == 0)
{
return;
}
$this->query_string = preg_replace('/^\/+|\/+$|\/(?=\/)/', '', $this->query_string);
foreach(explode('/',$this->query_string) as $Key => $Value)
{
if($Key == 0)
{
$Controller = $this->AssignController($Value);
}
if($Key == 1)
{
$this->AssignMethod($Value);
}else
{
$this->AssignParam($Value);
}
}
}
public function AssignController(String $Controller)
{
if(!empty($Controller))
{
}
}
public function AssignMethod(String $Method)
{
if(!empty($Method))
{
}
}
public function AssignParam(String $Param)
{
$this->params[] = $Param;
}
"Sanitize", .