Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ static time_t zend_accel_get_time(void)
# define zend_accel_get_time() time(NULL)
#endif

static inline bool is_cacheable_stream_path(const char *filename)
static inline bool is_cacheable_stream_path(const zend_string *filename)
{
return memcmp(filename, "file://", sizeof("file://") - 1) == 0 ||
memcmp(filename, "phar://", sizeof("phar://") - 1) == 0;
return zend_string_starts_with_literal(filename, "file://") ||
zend_string_starts_with_literal(filename, "phar://");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a new issue, but should this be zend_string_starts_with_literal_ci()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Dunno which URL standard we follow, but from RFC3986:

Although schemes are case-
insensitive, the canonical form is lowercase and documents that
specify schemes must do so with lowercase letters. An implementation
should accept uppercase letters as equivalent to lowercase in scheme
names (e.g., allow "HTTP" as well as "http") for the sake of
robustness but should only produce lowercase scheme names for
consistency.

So yes, in principle this should be accepted.
Most code in php-src seems to check for this case-insensitively, but e.g. ext/openssl does not.
Should be brought up in a separate issue and uniformized (on consensus).

}

/* O+ overrides PHP chdir() function and remembers the current working directory
Expand Down Expand Up @@ -1205,7 +1205,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
if (IS_ABSOLUTE_PATH(path, path_length)) {
/* pass */
} else if (UNEXPECTED(php_is_stream_path(path))) {
if (!is_cacheable_stream_path(path)) {
if (!is_cacheable_stream_path(str)) {
return NULL;
}
/* pass */
Expand Down Expand Up @@ -1903,7 +1903,7 @@ static zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int
bool from_memory; /* if the script we've got is stored in SHM */

if (php_is_stream_path(ZSTR_VAL(file_handle->filename)) &&
!is_cacheable_stream_path(ZSTR_VAL(file_handle->filename))) {
!is_cacheable_stream_path(file_handle->filename)) {
return accelerator_orig_compile_file(file_handle, type);
}

Expand Down Expand Up @@ -2047,7 +2047,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
return accelerator_orig_compile_file(file_handle, type);
}
persistent_script = zend_accel_hash_find(&ZCSG(hash), key);
} else if (UNEXPECTED(php_is_stream_path(ZSTR_VAL(file_handle->filename)) && !is_cacheable_stream_path(ZSTR_VAL(file_handle->filename)))) {
} else if (UNEXPECTED(php_is_stream_path(ZSTR_VAL(file_handle->filename)) && !is_cacheable_stream_path(file_handle->filename))) {
ZCG(cache_opline) = NULL;
ZCG(cache_persistent_script) = NULL;
return accelerator_orig_compile_file(file_handle, type);
Expand Down
Loading