]> granicus.if.org Git - php/commitdiff
fix extension detection for executable=2
authorGreg Beaver <cellog@php.net>
Wed, 23 Apr 2008 18:22:09 +0000 (18:22 +0000)
committerGreg Beaver <cellog@php.net>
Wed, 23 Apr 2008 18:22:09 +0000 (18:22 +0000)
ext/phar/phar.c

index 481930b976a6184cc773de4b12db2e4e73e3f004..4bb1d7e213ff8c9628d38c7ec12ff1081163d4b4 100644 (file)
@@ -1509,10 +1509,16 @@ static int phar_check_str(const char *fname, const char *ext_str, int ext_len, i
                }
        }
        /* data phars need only contain a single non-"." to be valid */
-       pos = strstr(ext_str, ".phar");
-       if (!(pos && (*(pos - 1) != '/')
-                               && (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) && *(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') {
-               return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+       if (!executable) {
+               pos = strstr(ext_str, ".phar");
+               if (!(pos && (*(pos - 1) != '/')
+                                       && (pos += 5) && (*pos == '\0' || *pos == '/' || *pos == '.')) && *(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') {
+                       return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+               }
+       } else {
+               if (*(ext_str + 1) != '.' && *(ext_str + 1) != '/' && *(ext_str + 1) != '\0') {
+                       return phar_analyze_path(fname, ext_str, ext_len, for_create TSRMLS_CC);
+               }
        }
        return FAILURE;
 }
@@ -1599,7 +1605,7 @@ next_extension:
        if (!pos) {
                return FAILURE;
        }
-       if (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) {
+       while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) {
                pos = strchr(pos + 1, '.');
                if (!pos) {
                        return FAILURE;