php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76684 Curl BC break with CURLOPT_URL with domain relative url
Submitted: 2018-07-30 12:14 UTC Modified: 2018-08-20 15:44 UTC
From: maggus dot staab+php at googlemail dot com Assigned: cmb (profile)
Status: Not a bug Package: cURL related
PHP Version: 7.2.8 OS:
Private report: No CVE-ID: None
 [2018-07-30 12:14 UTC] maggus dot staab+php at googlemail dot com
Description:
------------
when using domain relative urls with curl, this worked on php5 and also on php7.0

we are in the process of testing our software with php7.2 and see that we get a error in this case "<url> malformed".

I agree using the CURLOPT_URL option without absolute urls is not ideal, but since it worked in the past I would at least not expect a BC break with this behaviour in the php7.* series

Test script:
---------------
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, '/mytest');
        curl_exec($ch);
        
        $error = '';
        if (curl_errno($ch) != 0) {
            $error = curl_error($ch);
        }


var_dump($error);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-30 13:09 UTC] cmb@php.net
# php -v
PHP 5.6.15 (cli) (built: Oct 29 2015 12:40:36)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
# php 76684.php
string(15) "<url> malformed"
 [2018-08-20 15:44 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2018-08-20 15:44 UTC] cmb@php.net
I've checked the code[1], and besides a minor modification for
Windows regarding file:// URLs, the given URLs are passed
unmodified to libcurl.  Also according to the libcurl docs[2],
specifying a host is required.  If it worked for you on older
PHP versions, that's likely due to an older libcurl version.

[1] <https://github.com/php/php-src/blob/php-7.3.0beta2/ext/curl/interface.c#L197-L231>
[2] <https://curl.haxx.se/libcurl/c/CURLOPT_URL.html>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC