【发布时间】:2016-04-16 20:40:45
【问题描述】:
我正在使用 strpos 函数来验证用户提交的 url,并且我想确保我没有遗漏任何允许用户绕过验证并提交不适当的 url 的内容。
以以下为例,如果我只希望用户能够输入与 youtube 域关联的 url,我不希望他们能够在其中放置通配符 (*) 或其他内容“欺骗” strpos 函数。
$url = $request->input('url');
// Check if Youtube url is found
if (strpos($url, 'http://youtube.com') > -1)
{
// some code
}
// some code
谢谢!
【问题讨论】:
-
您还必须考虑 URL 缩短器
标签: php