@wp-playground/wordpress 2.0.13 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +28 -8
- package/index.cjs.map +1 -1
- package/index.js +33 -13
- package/index.js.map +1 -1
- package/package.json +7 -7
package/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@php-wasm/util"),p=require("@wp-playground/common"),c=require("@php-wasm/logger"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@php-wasm/util"),p=require("@wp-playground/common"),c=require("@php-wasm/logger"),l=require("@php-wasm/universal"),T=`<?php
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Rewrites the wp-config.php file to ensure specific constants are defined
|
|
@@ -352,7 +352,7 @@ function skip_whitespace($tokens) {
|
|
|
352
352
|
ob_clean();
|
|
353
353
|
echo false === $return_value ? '0' : '1';
|
|
354
354
|
ob_end_flush();
|
|
355
|
-
`})).text!=="1")throw new Error("Failed to rewrite constants in wp-config.php.")}async function h(e,r){const n=o.joinPaths(r,"wp-config.php"),t={DB_NAME:"wordpress"};!e.fileExists(n)&&e.fileExists(o.joinPaths(r,"wp-config-sample.php"))&&await e.writeFile(n,await e.readFileAsBuffer(o.joinPaths(r,"wp-config-sample.php"))),await _(e,n,t,"skip")}async function
|
|
355
|
+
`})).text!=="1")throw new Error("Failed to rewrite constants in wp-config.php.")}async function h(e,r){const n=o.joinPaths(r,"wp-config.php"),t={DB_NAME:"wordpress"};!e.fileExists(n)&&e.fileExists(o.joinPaths(r,"wp-config-sample.php"))&&await e.writeFile(n,await e.readFileAsBuffer(o.joinPaths(r,"wp-config-sample.php"))),await _(e,n,t,"skip")}async function v(e){var t,i;const r=await g(e),n=await r.getPrimaryPhp();if((t=e.hooks)!=null&&t.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(n),e.wordPressZip&&await k(n,await e.wordPressZip),e.constants)for(const s in e.constants)n.defineConstant(s,e.constants[s]);if(e.dataSqlPath&&(n.defineConstant("DB_DIR",o.dirname(e.dataSqlPath)),n.defineConstant("DB_FILE",o.basename(e.dataSqlPath))),n.defineConstant("WP_HOME",e.siteUrl),n.defineConstant("WP_SITEURL",e.siteUrl),await h(n,r.documentRoot),(i=e.hooks)!=null&&i.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(n),e.sqliteIntegrationPluginZip&&await P(n,await e.sqliteIntegrationPluginZip),!e.dataSqlPath&&(await f(n)||await R(n),!await f(n))){if(await S(n))throw new Error("WordPress installation has failed.");if(n.isFile("/internal/shared/preload/0-sqlite.php"))throw new Error("Error connecting to the SQLite database.");if(!e.sqliteIntegrationPluginZip){const a=o.joinPaths(r.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");if(n.isDir(a))throw new Error("Error connecting to the SQLite database.")}throw new Error("Error connecting to the MySQL database.")}return r}async function g(e){const r=e.spawnHandler??l.sandboxedSpawnHandlerFactory;async function n(i,s){const a=new l.PHP(await e.createPhpRuntime());return e.sapiName&&a.setSapiName(e.sapiName),i&&(a.requestHandler=i),e.phpIniEntries&&l.setPhpIniEntries(a,e.phpIniEntries),a.defineConstant("WP_SQLITE_AST_DRIVER",!0),s?(await b(a),await l.writeFiles(a,"/",e.createFiles||{}),await y(a,o.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php"))):l.proxyFileSystem(await i.getPrimaryPhp(),a,["/tmp",i.documentRoot,"/internal/shared","/internal/symlinks"]),r&&await a.setSpawnHandler(r(i.processManager)),l.rotatePHPRuntime({php:a,cwd:i.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(a),a}const t=new l.PHPRequestHandler({phpFactory:async({isPrimary:i})=>n(t,i),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:m,getFileNotFoundAction:e.getFileNotFoundAction??$,cookieStore:e.cookieStore});return t}async function f(e){return(await e.run({code:`<?php
|
|
356
356
|
ob_start();
|
|
357
357
|
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
|
|
358
358
|
if (!file_exists($wp_load)) {
|
|
@@ -363,7 +363,7 @@ function skip_whitespace($tokens) {
|
|
|
363
363
|
ob_clean();
|
|
364
364
|
echo is_blog_installed() ? '1' : '0';
|
|
365
365
|
ob_end_flush();
|
|
366
|
-
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function R(e){await
|
|
366
|
+
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function R(e){await l.withPHPIniValues(e,{disable_functions:"fsockopen",allow_url_fopen:"0"},async()=>await e.request({url:"/wp-admin/install.php?step=2",method:"POST",body:{language:"en",prefix:"wp_",weblog_title:"My WordPress Website",user_name:"admin",admin_password:"password",admin_password2:"password",Submit:"Install WordPress",pw_weak:"1",admin_email:"admin@localhost.com"}})),(await e.run({code:`<?php
|
|
367
367
|
ob_start();
|
|
368
368
|
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
|
|
369
369
|
if (!file_exists($wp_load)) {
|
|
@@ -378,7 +378,7 @@ function skip_whitespace($tokens) {
|
|
|
378
378
|
ob_clean();
|
|
379
379
|
echo $option_result ? '1' : '0';
|
|
380
380
|
ob_end_flush();
|
|
381
|
-
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text!=="1"&&c.logger.warn("Failed to default to pretty permalinks after WP install.")}function $(e){return{type:"internal-redirect",uri:"/index.php"}}async function
|
|
381
|
+
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text!=="1"&&c.logger.warn("Failed to default to pretty permalinks after WP install.")}function $(e){return{type:"internal-redirect",uri:"/index.php"}}async function S(e){return(await e.run({code:`<?php
|
|
382
382
|
ob_start();
|
|
383
383
|
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
|
|
384
384
|
if (!file_exists($wp_load)) {
|
|
@@ -389,7 +389,7 @@ function skip_whitespace($tokens) {
|
|
|
389
389
|
ob_clean();
|
|
390
390
|
echo $wpdb->check_connection( false) ? '1' : '0';
|
|
391
391
|
ob_end_flush();
|
|
392
|
-
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function
|
|
392
|
+
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function x(e){const{php:r,reap:n}=await e.processManager.acquirePHPInstance({considerPrimary:!0});try{const i=(await r.run({code:`<?php
|
|
393
393
|
require '${e.documentRoot}/wp-includes/version.php';
|
|
394
394
|
echo $wp_version;
|
|
395
395
|
`})).text;if(!i)throw new Error("Unable to read loaded WordPress version.");return w(i)}finally{n()}}function w(e){if(/-(alpha|beta|RC)\d*-\d+$/.test(e))return"nightly";if(/-(beta|RC)\d*$/.test(e))return"beta";const t=e.match(/^(\d+\.\d+)(?:\.\d+)?$/);return t!==null?t[1]:e}const m=[{match:/^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,replacement:"$2"}];async function b(e){await e.mkdir("/internal/shared/mu-plugins"),await e.writeFile("/internal/shared/preload/env.php",`<?php
|
|
@@ -584,6 +584,26 @@ function skip_whitespace($tokens) {
|
|
|
584
584
|
);
|
|
585
585
|
} );
|
|
586
586
|
|
|
587
|
+
/**
|
|
588
|
+
* Prevents wp_http_validate_url() from universally failing.
|
|
589
|
+
*
|
|
590
|
+
* wp_http_validate_url() calls gethostbyname() to verify whether the host
|
|
591
|
+
* is external. If it is internal, the URL validation fails and WordPress
|
|
592
|
+
* refuses to make a request.
|
|
593
|
+
*
|
|
594
|
+
* However, in EMscripten, gethostbyname() returns a private network IP address.
|
|
595
|
+
* This causes wp_http_validate_url() to return false for all URLs.
|
|
596
|
+
*
|
|
597
|
+
* This filter ensures that all URLs are considered external. In production
|
|
598
|
+
* environments, this would be considered a security risk. However, Playground
|
|
599
|
+
* already provides multiple code execution vectors as features (e.g. Blueprints).
|
|
600
|
+
*
|
|
601
|
+
* If someone wants to poke around local IP addresses, they already have multiple
|
|
602
|
+
* tools at their disposal. Therefore, this is not a real security risk in context
|
|
603
|
+
* of WordPress Playground or Playground CLI.
|
|
604
|
+
*/
|
|
605
|
+
add_filter('http_request_host_is_external', '__return_true');
|
|
606
|
+
|
|
587
607
|
// Support pretty permalinks
|
|
588
608
|
add_filter( 'got_url_rewrite', '__return_true' );
|
|
589
609
|
|
|
@@ -649,12 +669,12 @@ function skip_whitespace($tokens) {
|
|
|
649
669
|
phpinfo();
|
|
650
670
|
exit;
|
|
651
671
|
}
|
|
652
|
-
`)}async function P(e,r){await e.isDir("/tmp/sqlite-database-integration")&&await e.rmdir("/tmp/sqlite-database-integration",{recursive:!0}),await e.mkdir("/tmp/sqlite-database-integration"),await p.unzipFile(e,r,"/tmp/sqlite-database-integration");const n="/internal/shared/sqlite-database-integration",t=`/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;await e.mv(t,n),await e.defineConstant("SQLITE_MAIN_FILE","1");const s=(await e.readFileAsText(o.joinPaths(n,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",o.phpVar(n)).replace("'{SQLITE_PLUGIN}'",o.phpVar(o.joinPaths(n,"load.php"))),a=o.joinPaths(await e.documentRoot,"wp-content/db.php"),
|
|
672
|
+
`)}async function P(e,r){await e.isDir("/tmp/sqlite-database-integration")&&await e.rmdir("/tmp/sqlite-database-integration",{recursive:!0}),await e.mkdir("/tmp/sqlite-database-integration"),await p.unzipFile(e,r,"/tmp/sqlite-database-integration");const n="/internal/shared/sqlite-database-integration",t=`/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;await e.mv(t,n),await e.defineConstant("SQLITE_MAIN_FILE","1");const s=(await e.readFileAsText(o.joinPaths(n,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",o.phpVar(n)).replace("'{SQLITE_PLUGIN}'",o.phpVar(o.joinPaths(n,"load.php"))),a=o.joinPaths(await e.documentRoot,"wp-content/db.php"),d=`<?php
|
|
653
673
|
// Do not preload this if WordPress comes with a custom db.php file.
|
|
654
674
|
if(file_exists(${o.phpVar(a)})) {
|
|
655
675
|
return;
|
|
656
676
|
}
|
|
657
|
-
?>`,u="/internal/shared/mu-plugins/sqlite-database-integration.php";await e.writeFile(u,
|
|
677
|
+
?>`,u="/internal/shared/mu-plugins/sqlite-database-integration.php";await e.writeFile(u,d+s),await e.writeFile("/internal/shared/preload/0-sqlite.php",d+`<?php
|
|
658
678
|
|
|
659
679
|
/**
|
|
660
680
|
* Loads the SQLite integration plugin before WordPress is loaded
|
|
@@ -735,5 +755,5 @@ if(!function_exists('mysqli_connect')) {
|
|
|
735
755
|
var_dump(isset($wpdb));
|
|
736
756
|
die("SQLite integration not loaded " . get_class($wpdb));
|
|
737
757
|
}
|
|
738
|
-
`)}async function k(e,r){e.mkdir("/tmp/unzipped-wordpress"),await p.unzipFile(e,r,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await p.unzipFile(e,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");let n=e.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":e.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";if(!e.fileExists(o.joinPaths(n,"wp-config-sample.php"))){const i=e.listFiles(n);if(i.length){const s=i[0];e.fileExists(o.joinPaths(n,s,"wp-config-sample.php"))&&(n=o.joinPaths(n,s))}}const t=(i,s,a)=>{if(a.isDir(i)&&a.isDir(s))for(const
|
|
758
|
+
`)}async function k(e,r){e.mkdir("/tmp/unzipped-wordpress"),await p.unzipFile(e,r,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await p.unzipFile(e,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");let n=e.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":e.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";if(!e.fileExists(o.joinPaths(n,"wp-config-sample.php"))){const i=e.listFiles(n);if(i.length){const s=i[0];e.fileExists(o.joinPaths(n,s,"wp-config-sample.php"))&&(n=o.joinPaths(n,s))}}const t=(i,s,a)=>{if(a.isDir(i)&&a.isDir(s))for(const d of a.listFiles(i)){const u=o.joinPaths(i,d),E=o.joinPaths(s,d);t(u,E,a)}else{if(a.fileExists(s)){const d=i.replace(/^\/tmp\/unzipped-wordpress\//,"/");c.logger.warn(`Skipping ${d} because something exists at the target path.`);return}a.mv(i,s)}};t(n,e.documentRoot,e),e.fileExists(n)&&e.rmdir(n,{recursive:!0}),!e.fileExists(o.joinPaths(e.documentRoot,"wp-config.php"))&&e.fileExists(o.joinPaths(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(o.joinPaths(e.documentRoot,"wp-config.php"),e.readFileAsText(o.joinPaths(e.documentRoot,"/wp-config-sample.php")))}const L=p.createMemoizedFetch(fetch);async function I(e="latest"){if(e.startsWith("https://")||e.startsWith("http://")){const t=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(e)),i=Array.from(new Uint8Array(t)).map(s=>s.toString(16).padStart(2,"0")).join("");return{releaseUrl:e,version:"custom-"+i.substring(0,8),source:"inferred"}}else if(e==="trunk"||e==="nightly")return{releaseUrl:"https://wordpress.org/nightly-builds/wordpress-latest.zip",version:"nightly-"+new Date().toISOString().split("T")[0],source:"inferred"};let n=await(await L("https://api.wordpress.org/core/version-check/1.7/?channel=beta")).json();n=n.offers.filter(t=>t.response==="autoupdate");for(const t of n){if(e==="beta"&&t.version.includes("beta"))return{releaseUrl:t.download,version:t.version,source:"api"};if(e==="latest"&&!t.version.includes("beta"))return{releaseUrl:t.download,version:t.version,source:"api"};if(t.version.substring(0,e.length)===e)return{releaseUrl:t.download,version:t.version,source:"api"}}return{releaseUrl:`https://wordpress.org/wordpress-${e}.zip`,version:e,source:"inferred"}}exports.bootRequestHandler=g;exports.bootWordPress=v;exports.defineWpConfigConstants=_;exports.ensureWpConfig=h;exports.getFileNotFoundActionForWordPress=$;exports.getLoadedWordPressVersion=x;exports.preloadPhpInfoRoute=y;exports.preloadSqliteIntegration=P;exports.resolveWordPressRelease=I;exports.setupPlatformLevelMuPlugins=b;exports.unzipWordPress=k;exports.versionStringToLoadedWordPressVersion=w;exports.wordPressRewriteRules=m;
|
|
739
759
|
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { phpVars as h, joinPaths as s, dirname as g, basename as $, phpVar as l } from "@php-wasm/util";
|
|
2
2
|
import { createMemoizedFetch as w, unzipFile as p } from "@wp-playground/common";
|
|
3
3
|
import { logger as c } from "@php-wasm/logger";
|
|
4
|
-
import { sandboxedSpawnHandlerFactory as m, PHPRequestHandler as b, withPHPIniValues as y, PHP as k, setPhpIniEntries as P, writeFiles as E, proxyFileSystem as T, rotatePHPRuntime as
|
|
4
|
+
import { sandboxedSpawnHandlerFactory as m, PHPRequestHandler as b, withPHPIniValues as y, PHP as k, setPhpIniEntries as P, writeFiles as E, proxyFileSystem as T, rotatePHPRuntime as v } from "@php-wasm/universal";
|
|
5
5
|
const R = `<?php
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -348,7 +348,7 @@ function skip_whitespace($tokens) {
|
|
|
348
348
|
return $output;
|
|
349
349
|
}
|
|
350
350
|
`;
|
|
351
|
-
async function
|
|
351
|
+
async function S(e, r, n, t = "rewrite") {
|
|
352
352
|
const i = h({ wpConfigPath: r, constants: n, whenAlreadyDefined: t });
|
|
353
353
|
if ((await e.run({
|
|
354
354
|
code: `<?php ob_start(); ?>
|
|
@@ -373,15 +373,15 @@ async function x(e, r) {
|
|
|
373
373
|
await e.readFileAsBuffer(
|
|
374
374
|
s(r, "wp-config-sample.php")
|
|
375
375
|
)
|
|
376
|
-
), await
|
|
376
|
+
), await S(e, n, t, "skip");
|
|
377
377
|
}
|
|
378
378
|
async function Q(e) {
|
|
379
379
|
var t, i;
|
|
380
380
|
const r = await L(e), n = await r.getPrimaryPhp();
|
|
381
|
-
if ((t = e.hooks) != null && t.beforeWordPressFiles && await e.hooks.beforeWordPressFiles(n), e.wordPressZip && await
|
|
381
|
+
if ((t = e.hooks) != null && t.beforeWordPressFiles && await e.hooks.beforeWordPressFiles(n), e.wordPressZip && await F(n, await e.wordPressZip), e.constants)
|
|
382
382
|
for (const o in e.constants)
|
|
383
383
|
n.defineConstant(o, e.constants[o]);
|
|
384
|
-
if (e.dataSqlPath && (n.defineConstant("DB_DIR", g(e.dataSqlPath)), n.defineConstant("DB_FILE", $(e.dataSqlPath))), n.defineConstant("WP_HOME", e.siteUrl), n.defineConstant("WP_SITEURL", e.siteUrl), await x(n, r.documentRoot), (i = e.hooks) != null && i.beforeDatabaseSetup && await e.hooks.beforeDatabaseSetup(n), e.sqliteIntegrationPluginZip && await
|
|
384
|
+
if (e.dataSqlPath && (n.defineConstant("DB_DIR", g(e.dataSqlPath)), n.defineConstant("DB_FILE", $(e.dataSqlPath))), n.defineConstant("WP_HOME", e.siteUrl), n.defineConstant("WP_SITEURL", e.siteUrl), await x(n, r.documentRoot), (i = e.hooks) != null && i.beforeDatabaseSetup && await e.hooks.beforeDatabaseSetup(n), e.sqliteIntegrationPluginZip && await q(
|
|
385
385
|
n,
|
|
386
386
|
await e.sqliteIntegrationPluginZip
|
|
387
387
|
), !e.dataSqlPath && (await f(n) || await I(n), !await f(n))) {
|
|
@@ -417,7 +417,7 @@ async function L(e) {
|
|
|
417
417
|
"/internal/symlinks"
|
|
418
418
|
]), r && await a.setSpawnHandler(
|
|
419
419
|
r(i.processManager)
|
|
420
|
-
),
|
|
420
|
+
), v({
|
|
421
421
|
php: a,
|
|
422
422
|
cwd: i.documentRoot,
|
|
423
423
|
recreateRuntime: e.createPhpRuntime,
|
|
@@ -756,6 +756,26 @@ async function D(e) {
|
|
|
756
756
|
);
|
|
757
757
|
} );
|
|
758
758
|
|
|
759
|
+
/**
|
|
760
|
+
* Prevents wp_http_validate_url() from universally failing.
|
|
761
|
+
*
|
|
762
|
+
* wp_http_validate_url() calls gethostbyname() to verify whether the host
|
|
763
|
+
* is external. If it is internal, the URL validation fails and WordPress
|
|
764
|
+
* refuses to make a request.
|
|
765
|
+
*
|
|
766
|
+
* However, in EMscripten, gethostbyname() returns a private network IP address.
|
|
767
|
+
* This causes wp_http_validate_url() to return false for all URLs.
|
|
768
|
+
*
|
|
769
|
+
* This filter ensures that all URLs are considered external. In production
|
|
770
|
+
* environments, this would be considered a security risk. However, Playground
|
|
771
|
+
* already provides multiple code execution vectors as features (e.g. Blueprints).
|
|
772
|
+
*
|
|
773
|
+
* If someone wants to poke around local IP addresses, they already have multiple
|
|
774
|
+
* tools at their disposal. Therefore, this is not a real security risk in context
|
|
775
|
+
* of WordPress Playground or Playground CLI.
|
|
776
|
+
*/
|
|
777
|
+
add_filter('http_request_host_is_external', '__return_true');
|
|
778
|
+
|
|
759
779
|
// Support pretty permalinks
|
|
760
780
|
add_filter( 'got_url_rewrite', '__return_true' );
|
|
761
781
|
|
|
@@ -835,7 +855,7 @@ async function A(e, r = "/phpinfo.php") {
|
|
|
835
855
|
`
|
|
836
856
|
);
|
|
837
857
|
}
|
|
838
|
-
async function
|
|
858
|
+
async function q(e, r) {
|
|
839
859
|
await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
|
|
840
860
|
recursive: !0
|
|
841
861
|
}), await e.mkdir("/tmp/sqlite-database-integration"), await p(e, r, "/tmp/sqlite-database-integration");
|
|
@@ -944,7 +964,7 @@ if(!function_exists('mysqli_connect')) {
|
|
|
944
964
|
`
|
|
945
965
|
);
|
|
946
966
|
}
|
|
947
|
-
async function
|
|
967
|
+
async function F(e, r) {
|
|
948
968
|
e.mkdir("/tmp/unzipped-wordpress"), await p(e, r, "/tmp/unzipped-wordpress"), e.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await p(
|
|
949
969
|
e,
|
|
950
970
|
"/tmp/unzipped-wordpress/wordpress.zip",
|
|
@@ -987,7 +1007,7 @@ async function N(e, r) {
|
|
|
987
1007
|
)
|
|
988
1008
|
);
|
|
989
1009
|
}
|
|
990
|
-
const
|
|
1010
|
+
const N = w(fetch);
|
|
991
1011
|
async function V(e = "latest") {
|
|
992
1012
|
if (e.startsWith("https://") || e.startsWith("http://")) {
|
|
993
1013
|
const t = await crypto.subtle.digest(
|
|
@@ -1005,7 +1025,7 @@ async function V(e = "latest") {
|
|
|
1005
1025
|
version: "nightly-" + (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
1006
1026
|
source: "inferred"
|
|
1007
1027
|
};
|
|
1008
|
-
let n = await (await
|
|
1028
|
+
let n = await (await N(
|
|
1009
1029
|
"https://api.wordpress.org/core/version-check/1.7/?channel=beta"
|
|
1010
1030
|
)).json();
|
|
1011
1031
|
n = n.offers.filter(
|
|
@@ -1040,15 +1060,15 @@ async function V(e = "latest") {
|
|
|
1040
1060
|
export {
|
|
1041
1061
|
L as bootRequestHandler,
|
|
1042
1062
|
Q as bootWordPress,
|
|
1043
|
-
|
|
1063
|
+
S as defineWpConfigConstants,
|
|
1044
1064
|
x as ensureWpConfig,
|
|
1045
1065
|
U as getFileNotFoundActionForWordPress,
|
|
1046
1066
|
z as getLoadedWordPressVersion,
|
|
1047
1067
|
A as preloadPhpInfoRoute,
|
|
1048
|
-
|
|
1068
|
+
q as preloadSqliteIntegration,
|
|
1049
1069
|
V as resolveWordPressRelease,
|
|
1050
1070
|
D as setupPlatformLevelMuPlugins,
|
|
1051
|
-
|
|
1071
|
+
F as unzipWordPress,
|
|
1052
1072
|
W as versionStringToLoadedWordPressVersion,
|
|
1053
1073
|
C as wordPressRewriteRules
|
|
1054
1074
|
};
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/wordpress",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.15",
|
|
4
4
|
"description": "WordPress-related plumbing for WordPress Playground",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"access": "public",
|
|
36
36
|
"directory": "../../../dist/packages/playground/wordpress"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "f3f73a4fc48bbe3ae099da4c1418d2f125d16d0a",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"express": "4.21.2",
|
|
41
41
|
"ini": "4.1.2",
|
|
42
42
|
"wasm-feature-detect": "1.8.0",
|
|
43
43
|
"ws": "8.18.1",
|
|
44
44
|
"yargs": "17.7.2",
|
|
45
|
-
"@php-wasm/universal": "2.0.
|
|
46
|
-
"@php-wasm/util": "2.0.
|
|
47
|
-
"@php-wasm/logger": "2.0.
|
|
48
|
-
"@wp-playground/common": "2.0.
|
|
49
|
-
"@php-wasm/node": "2.0.
|
|
45
|
+
"@php-wasm/universal": "2.0.15",
|
|
46
|
+
"@php-wasm/util": "2.0.15",
|
|
47
|
+
"@php-wasm/logger": "2.0.15",
|
|
48
|
+
"@wp-playground/common": "2.0.15",
|
|
49
|
+
"@php-wasm/node": "2.0.15"
|
|
50
50
|
},
|
|
51
51
|
"overrides": {
|
|
52
52
|
"rollup": "^4.34.6",
|