keycdn / cache-enabler

A lightweight caching plugin for WordPress that makes your website faster by generating static HTML files.
https://wordpress.org/plugins/cache-enabler/
123 stars 46 forks source link

update directory object filter #245

Closed coreykn closed 3 years ago

coreykn commented 3 years ago

Update directory object filter to always force strict matches and only continue allowing wildcard matches if an asterisk (*) is the last character. Before this change, wildcard matches were allowed by default with no delimiter, potentially allowing a false match to occur.

For example, previously if the nested directory object being checked was /path/to/object-1/ and the filter given was /path/to/object then /path/to/object-1/ would be included. This was not intended, which is why the trailing slash was originally appended to create the $nested_dir_object variable. This prevented false matches in the future inclusion check, but not the past inclusion check. By also appending the trailing slash to the filter object, which would be /path/to/object/ in this example, this will not occur.

A wildcard match is still however needed in some cases, like a change to the system cache clearing that I will be introducing after this. Providing a trailing asterisk will allow that wildcard matching behavior to continue, where if /path/to/object-* was the filter it would match /path/to/object-1, /path/to/object-2, etc. This same behavior has been extended for exclusions as well now (e.g. if /path/to/object-* was the excluded filter it would match everything but /path/to/object-1, /path/to/object-2, etc.).

This updates what was originally added in #237.