From 999961f080c7456f88b34fb70969e7bc6f6b247f Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Tue, 13 Nov 2007 05:57:14 +0000 Subject: [PATCH] begin win32 fixes for Phar object - still have a problem I can't track down yet, but it's only a matter of time before it is killed too when passing in a full path with drive letter to the Phar object, we were then passing "phar://C:/path/to/blah.phar" to php_parse_url(), which thinks it is getting a valid url scheme "phar", host "C" path "/path/to/blah.phar" we now pass "phar:///C:/path/to/blah.phar" to make it fail, and then properly parse the url inside phar --- ext/phar/phar.c | 7 +++++++ ext/phar/phar_object.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 521bd69bde..386d11449b 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1482,6 +1482,13 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le filename_len -= 7; } +#ifdef PHP_WIN32 + if (filename_len > 3 && *filename == '/' && *(filename + 2) == ':' && *(filename + 3) == '/') { + filename++; + filename_len--; + } +#endif + if (phar_detect_phar_fname_ext(filename, 0, &ext_str, &ext_len) == FAILURE) { return FAILURE; } diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 64b3a77f1c..684fd128d3 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -244,7 +244,16 @@ PHP_METHOD(Phar, __construct) phar_obj->arc.archive = phar_data; phar_obj->spl.oth_handler = &phar_spl_foreign_handler; +#ifdef PHP_WIN32 + /* check for drive filenames like C:/ and prepend / */ + if (fname_len > 2 && *(fname + 1) == ':' && *(fname + 2) == '/') { + fname_len = spprintf(&fname, 0, "phar:///%s", fname); + } else { + fname_len = spprintf(&fname, 0, "phar://%s", fname); + } +#else fname_len = spprintf(&fname, 0, "phar://%s", fname); +#endif INIT_PZVAL(&arg1); ZVAL_STRINGL(&arg1, fname, fname_len, 0); -- 2.50.1