Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions packages/playground/blueprints/src/lib/steps/import-wxr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export const importWxr: StepHandler<ImportWxrStep<File>> = async (
await playground.run({
code: `<?php
require ${phpVar(docroot)} . '/wp-load.php';
if ( ! function_exists( 'wp_crop_image' ) ) {
include( ABSPATH . 'wp-admin/includes/image.php' );
}
include( ABSPATH . 'wp-admin/includes/media.php' );
kses_remove_filters();
$admin_id = get_users(array('role' => 'Administrator') )[0];
$importer = new WXR_Importer( array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export async function setupFetchNetworkTransport(playground: UniversalPHP) {

export async function handleRequest(data: RequestData, fetchFn = fetch) {
const hostname = new URL(data.url).hostname;
const fetchUrl = ['w.org', 's.w.org'].includes(hostname)
const fetchUrl = [
'w.org',
's.w.org',
'wpthemetestdata.files.wordpress.com',
].includes(hostname)
? `/plugin-proxy.php?url=${encodeURIComponent(data.url)}`
: data.url;

Expand Down
2 changes: 1 addition & 1 deletion packages/playground/website/public/plugin-proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function ($curl, $body) use (&$extra_headers_sent, $default_response_headers) {
// Proxy the current request to $_GET['url'] and return the response,
// but only if the URL is allowlisted.
$url = $_GET['url'];
$allowed_domains = ['api.wordpress.org', 'w.org', 'wordpress.org', 's.w.org'];
$allowed_domains = ['api.wordpress.org', 'w.org', 'wordpress.org', 's.w.org', 'wpthemetestdata.files.wordpress.com'];
$parsed_url = parse_url($url);
if (!in_array($parsed_url['host'], $allowed_domains)) {
http_response_code(403);
Expand Down