Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 使codeigniter在$#GET';s_Regex_Codeigniter_Codeigniter Url - Fatal编程技术网

Regex 使codeigniter在$#GET';s

Regex 使codeigniter在$#GET';s,regex,codeigniter,codeigniter-url,Regex,Codeigniter,Codeigniter Url,我在CI处理$\u GET时遇到了一个问题,并找到了一种解决方法 问题是,您能在这里看到任何安全问题吗? 我有我的网址的所有方式像 /contacts /company/info 我在CodeIgniter上的默认控制器称为index 只要遵循类/函数/default\u控制器,我就可以使CI在$\u GET下运行 这两个URL的工作: // class + function + default controller = ok /class/function/index?var1=this&a

我在CI处理$\u GET时遇到了一个问题,并找到了一种解决方法

问题是,您能在这里看到任何安全问题吗?

我有我的网址的所有方式像

/contacts
/company/info
我在CodeIgniter上的默认控制器称为index

只要遵循
类/函数/default\u控制器
,我就可以使CI在
$\u GET
下运行

这两个URL的工作:

// class + function + default controller = ok
/class/function/index?var1=this&var2=that

// class + default controller = ok
/class/index?var1=this&var2=that
问题是我希望这些也能起作用

// class without function nor default controller = NOT OK
/class?var1=this&var2=that

// class + function without default controller = NOT OK
/class/function?var1=this&var2=that
我的解决方案是在
$\u服务器['REQUEST\u URI']
上使用一个小正则表达式

我不是正则表达式的专家,所以,你能看到这里可能存在的安全问题吗

/*
|---------------------------------------------------------------
| MAKE CODEIGNITER BEHAVE ON _GETS!
|---------------------------------------------------------------
|
| CI doesn't like to play ball with /contacts?a=23 and fails on several ocasions
| This forces the first ? or & to be replaced by /index/ that is the default controller
|
*/
 $_SERVER['REQUEST_URI'] = preg_replace('/\?|\&/', '/index/', $_SERVER['REQUEST_URI'], 1);

谢谢。

没有。只要你不盲目地相信$_GET[](你无论如何都不应该相信),你就很好