php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73506 php_url_parse_ex does not support resource id in url scheme
Submitted: 2016-11-12 15:48 UTC Modified: 2016-11-13 16:07 UTC
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:1 (20.0%)
From: firestorm9 at gmail dot com Assigned:
Status: Wont fix Package: Streams related
PHP Version: 5.6.28 OS: Linux
Private report: No CVE-ID: None
 [2016-11-12 15:48 UTC] firestorm9 at gmail dot com
Description:
------------
The code in php_url_parse_ex was changed in a way that does no longer support "Resource id #8" in a url scheme.

Reverting the code in ext/standard/url.c at line 220 fixes the issue:

//  e = s + strcspn(s, "/?#");

    if (!(p = memchr(s, '/', (ue - s)))) {
        char *query, *fragment;

        query = memchr(s, '?', (ue - s));
        fragment = memchr(s, '#', (ue - s));

        if (query && fragment) {
            if (query > fragment) {
                e = fragment;
            } else {
                e = query;
            }
        } else if (query) {
            e = query;
        } else if (fragment) {
            e = fragment;
        }
    } else {
        e = p;
    }


Test script:
---------------
<?php

error_reporting(-1);

$host     = 'any.sftp.host';
$port     = 22;
$path     = '/a/valid/path';
$username = 'user';
$password = 'pass';

$filename = 'zzz-test.txt';

$textOutput = "This is a test\n\ntest\ntest\ntest\ntest\ntest\n";

try {

    $sshConnection = ssh2_connect($host, $port);

    if (! $sshConnection) {
        die("Failed to open connection to $host.\n");
    }

    echo "Connection established\n";

    ssh2_auth_password($sshConnection, $username, $password);

    $sftp = ssh2_sftp($sshConnection);
    $sftpStream = @fopen("ssh2.sftp://$sftp" . $path . $filename, 'w');

} catch(Exception $e) {
    die("Failed to open SFTP connection to $host: " . $e->getMessage() . "\n");
}

if (!$sftpStream) { die("Failed to open stream to $host\n"); }
echo "Stream opened";

try {
    $writeResult = @fwrite($sftpStream, $orderOutput);
} catch(Exception $e) {
    die("Failed to write $path/$filename to $host: " . $e->getMessage() . "\n");
}

if ($writeResult === false) {
    die("Failed to write $path/$filename to $host\n");
}

echo "Stream wrote successfully\n";
fclose($sftpStream);
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-13 16:07 UTC] ab@php.net
-Status: Open +Status: Wont fix
 [2016-11-13 16:07 UTC] ab@php.net
See bug #73192. AFAIR, the fix for ext/ssh2 is on the way.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC