You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Treat zip files as zip files regardless of file name (#58)
## Motivation for the change, related issues
There are cases where we are processing a treating a zip file as a PHP
file due to a file name ending in ".php".
A zip file downloaded by plugin-proxy.php may end up with the name
"plugin-proxy.php" due to how FetchResource works:
https://github.com/WordPress/wordpress-playground/blob/0deba0eacfd4a4c3057e6ad58e1b0cab177195af/packages/playground/blueprints/src/lib/resources.ts#L366-L368
We could tweak how we name downloaded resources to avoid this particular
issue, but in general, we cannot determine the name of downloaded
resources based on URL alone. Any kind of URL can point to a zip file,
and the web server may or may not respond with a suggested name for a
resource. There are cases where we need a default file name, and at the
moment, we default to a name based on the URL path.
IMO, this is fine. We can take responsibility for what we do with the
fetched data in the steps that use it.
In this case, let's update the installPlugin step to to treat a zip file
as a zip even if its name ends in ".php".
## Implementation details
This PR updates the installPlugin step to check if a file is a zip
before treating it as any other file type based on extension. Before
this change, the step assumes every file with a name ending in ".php" is
a single file WordPress plugin. (I introduced this single-php-file
install behavior in 6c54e29).
## Testing Instructions (or ideally a Blueprint)
- CI
0 commit comments