【问题标题】:file_exists with reserved filenames bug文件名存在保留文件名错误
【发布时间】:2011-08-16 04:15:19
【问题描述】:

好的,这是我的代码

        $ref = $_GET['ref'];
        if (file_exists('views/'.$ref.'.php')) {
            $this->prepare($ref);
        } 
        elseif (!file_exists('views/'.$ref.'.php')) {
        echo 'Page you are requesting doesn´t exist';
        }

如果用户尝试执行 ?ref=con 或 ?ref=com1 等操作,我目前遇到问题,file_exists 将始终返回 true。有解决办法吗?

【问题讨论】:

  • 您可以移动到不会发生这种情况的 Un*x 服务器。可能还有一些注册表补丁可以禁用那些旧的 DOS 兼容性设备文件名。或者尝试使用那些 NT fs 前缀 msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx 之一
  • @mario:你应该这样回答。我不知道那些是保留的文件名。

标签: php filenames file-exists reserved


【解决方案1】:

可能是因为这些文件确实存在。我会更担心被滥用的可能性。你应该过滤你的输入。

elseif 也是不必要的。 else 就足够了。

【讨论】:

  • 谢谢。是的,我确实对它们进行了消毒。这些文件不存在,我认为它只是一个错误或什么的。
【解决方案2】:

【讨论】:

  • 谢谢,“常规”文件是什么意思?
猜你喜欢
  • 2020-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-09
相关资源
最近更新 更多