Skip to content

Commit 06f6e47

Browse files
committed
Require that wrappers use <protocol>://<path> to avoid
ambiguities when filenames have ':' characters. This slightly breaks BC with the old style zlib: wrapper.
1 parent 8c0fd5b commit 06f6e47

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

ext/standard/php_fopen_wrapper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ php_stream * php_stream_url_wrap_php(char * path, char * mode, int options, char
3434
{
3535
FILE * fp = NULL;
3636
php_stream * stream = NULL;
37+
38+
if (!strncasecmp(path, "php://", 6))
39+
path += 6;
3740

3841
if (!strcasecmp(path, "stdin")) {
3942
fp = fdopen(dup(STDIN_FILENO), mode);

ext/zlib/zlib_fopen_wrapper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened
9999

100100
self = emalloc(sizeof(*self));
101101

102-
if (strncmp("zlib:", path, 5) == 0)
103-
path += 5;
102+
if (strncasecmp("zlib://", path, 7) == 0)
103+
path += 7;
104104

105105
self->stream = php_stream_open_wrapper(path, mode, STREAM_MUST_SEEK|options, opened_path);
106106

main/streams.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ static php_stream *php_stream_open_url(char *path, char *mode, int options, char
10291029
n++;
10301030
}
10311031

1032-
if ((*p == ':') && (n > 1)) {
1032+
if ((*p == ':') && (n > 1) && !strncmp("://", p, 3)) {
10331033
protocol = path;
10341034
}
10351035

0 commit comments

Comments
 (0)