douhan5547 2010-02-03 23:15
浏览 33
已采纳

当我不需要它时,php逃脱

I've got an issue whereby PHP is escaping where I really don't want it to in this code:

        $url_ = stripslashes(((substr(strtolower($url),0,7)!="http://")? "http://".$url:$url));
        $host = $this->googleDomains[mt_rand(0,count($this->googleDomains)-1)];
        $target = "/search?";
        $querystring = sprintf("client=navclient-auto&ch=%s&features=Rank&q=%s",
            $this->CheckHash($this->HashURL($url_)),urlencode("info:".$url_));
        $contents="";

        $this->debugRes("host", $host);
        $this->debugRes("query_string", $querystring);
        $this->debugRes("user_agent", $this->userAgent);

thus producing a URL like this which causes the script to fail:

{"urls":[{"url":"hostcule.com","converted_url":"http:\/\/toolbarqueries.google.com\/search??client=navclient-auto&ch=74451333464&features=Rank&q=info%3Ahttp%3A%2F%2Fhostcule.com"}]}

How do I stop it?

Magic Quotes are Off.

Here's the $url comes from:

foreach (preg_split('#[
]+#', $_POST['urls']) as $url) {
        $url = trim($url);
        if ($url)
            $_SESSION['converted_urls'][] = array('url' => $url, 'converted_url' => $pr->GetPR($url, true, true));
    }

At this stage, $_POST['urls'] looks like:

{"urls":[{"url":"hostcule.com","converted_url":"http:\/\/www.google.com\/search??client=navclient-auto&ch=74451333464&features=Rank&q=info%3Ahttp%3A%2F%2Fhostcule.com"}]}

whilst $url looks like

 {"urls":[{"url":"hostcule.com","converted_url":"http:\/\/www.google.com\/search??client=navclient-auto&ch=74451333464&features=Rank&q=info%3Ahttp%3A%2F%2Fhostcule.com"}]}
  • 写回答

3条回答 默认 最新

  • duanqiao1961 2010-02-03 23:17
    关注

    There is nothing in that code that would produce the code you quote.

    My suspicion is that $url already contains the garbled http\/\/, and therefore your http:// recognizing mechanism never triggers.

    You need to step back and look where $url comes from. There is where your problem will be.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比