php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71368 FILTER_VALIDATE_URL rejects URLs starting with phar:///
Submitted: 2016-01-14 11:52 UTC Modified: 2021-03-12 12:41 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bschussek at gmail dot com Assigned:
Status: Open Package: Filter related
PHP Version: 7.0.2 OS: Ubuntu 14.04 LTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bschussek at gmail dot com
New email:
PHP Version: OS:

 

 [2016-01-14 11:52 UTC] bschussek at gmail dot com
Description:
------------
FILTER_VALIDATE_URLS rejects URLs starting with "phar:///".

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

var_dump(filter_var('file://c:/path/to/dir', FILTER_VALIDATE_URL));
var_dump(filter_var('file:///path/to/dir', FILTER_VALIDATE_URL));
var_dump(filter_var('phar://c:/path/to/dir', FILTER_VALIDATE_URL));
var_dump(filter_var('phar:///path/to/dir', FILTER_VALIDATE_URL));

Expected result:
----------------
string(21) "file://c:/path/to/dir"
string(19) "file:///path/to/dir"
string(21) "phar://c:/path/to/dir"
string(19) "phar:///path/to/dir"


Actual result:
--------------
string(21) "file://c:/path/to/dir"
string(19) "file:///path/to/dir"
string(21) "phar://c:/path/to/dir"
bool(false)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-15 16:42 UTC] cmb@php.net
This is because these URLs are rejected by parse_url()[1].

[1] <https://3v4l.org/uaF2G>
 [2021-03-12 12:41 UTC] cmb@php.net
More specifically, there is no special support for the phar
protocol in parse_url_ex2(), but there is for the file
protocol[1].

[1] <https://github.com/php/php-src/blob/php-7.4.16/ext/standard/url.c#L175-L176>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 19:01:32 2024 UTC