diff --git a/wp-includes/js/service-worker-navigation-routing.js b/wp-includes/js/service-worker-navigation-routing.js index 3231a0d47..a0c7be38b 100644 --- a/wp-includes/js/service-worker-navigation-routing.js +++ b/wp-includes/js/service-worker-navigation-routing.js @@ -65,9 +65,9 @@ ERROR_OFFLINE_BODY_FRAGMENT_URL, STREAM_HEADER_FRAGMENT_QUERY_VAR, NAVIGATION_BL headers: errorResponse.headers }; - let body = text.replace( //, errorMessages.error ); + let body = text.replace( /[<]!--WP_SERVICE_WORKER_ERROR_MESSAGE-->/, errorMessages.error ); body = body.replace( - /()((?:.|\n)+?)()/, + /([<]!--WP_SERVICE_WORKER_ERROR_TEMPLATE_BEGIN-->)((?:.|\n)+?)([<]!--WP_SERVICE_WORKER_ERROR_TEMPLATE_END-->)/, ( details ) => { if ( ! responseBody ) { return ''; // Remove the details from the document entirely. @@ -86,8 +86,8 @@ ERROR_OFFLINE_BODY_FRAGMENT_URL, STREAM_HEADER_FRAGMENT_QUERY_VAR, NAVIGATION_BL details = details.replace( '{{{iframe_srcdoc}}}', srcdoc ); // Replace the comments. - details = details.replace( '', '' ); - details = details.replace( '', '' ); + details = details.replace( '<' + '!--WP_SERVICE_WORKER_ERROR_TEMPLATE_BEGIN-->', '' ); + details = details.replace( '<' + '!--WP_SERVICE_WORKER_ERROR_TEMPLATE_END-->', '' ); return details; } ); @@ -111,7 +111,7 @@ ERROR_OFFLINE_BODY_FRAGMENT_URL, STREAM_HEADER_FRAGMENT_QUERY_VAR, NAVIGATION_BL headers: response.headers }; - const body = text.replace( //, errorMessages.default ); + const body = text.replace( /[<]!--WP_SERVICE_WORKER_ERROR_MESSAGE-->/, errorMessages.default ); return new Response( body, init ); } ); diff --git a/wp-includes/js/service-worker-offline-commenting.js b/wp-includes/js/service-worker-offline-commenting.js index 59bea598e..20575b293 100644 --- a/wp-includes/js/service-worker-offline-commenting.js +++ b/wp-includes/js/service-worker-offline-commenting.js @@ -29,9 +29,9 @@ headers: errorResponse.headers }; - let body = text.replace( //, errorMessages.error ); + let body = text.replace( /[<]!--WP_SERVICE_WORKER_ERROR_MESSAGE-->/, errorMessages.error ); body = body.replace( - /()((?:.|\n)+?)()/, + /([<]!--WP_SERVICE_WORKER_ERROR_TEMPLATE_BEGIN-->)((?:.|\n)+?)([<]!--WP_SERVICE_WORKER_ERROR_TEMPLATE_END-->)/, ( details ) => { if ( ! errorText ) { return ''; // Remove the details from the document entirely. @@ -50,8 +50,8 @@ details = details.replace( '{{{iframe_srcdoc}}}', srcdoc ); // Replace the comments. - details = details.replace( '', '' ); - details = details.replace( '', '' ); + details = details.replace( '<' + '!--WP_SERVICE_WORKER_ERROR_TEMPLATE_BEGIN-->', '' ); + details = details.replace( '<' + '!--WP_SERVICE_WORKER_ERROR_TEMPLATE_END-->', '' ); return details; } ); @@ -93,7 +93,7 @@ headers: response.headers }; - const body = text.replace( //, errorMessages.comment ); + const body = text.replace( /[<]!--WP_SERVICE_WORKER_ERROR_MESSAGE-->/, errorMessages.comment ); return new Response( body, init ); } );