Skip to content

Commit 9c6eb3a

Browse files
committed
Customize: Initialize matchedAllowedPath to empty string to avoid ternary guard.
See #65030.
1 parent 54a0191 commit 9c6eb3a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/js/_enqueues/wp/customize/controls.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6574,7 +6574,7 @@
65746574
*/
65756575

65766576
previewer.add( 'previewUrl', params.previewUrl ).setter( function( to ) {
6577-
var result = null, urlParser, queryParams, parsedAllowedUrl, matchedAllowedPath, parsedCandidateUrls = [];
6577+
var result = null, urlParser, queryParams, parsedAllowedUrl, matchedAllowedPath = '', parsedCandidateUrls = [];
65786578
urlParser = document.createElement( 'a' );
65796579
urlParser.href = to;
65806580

@@ -6616,7 +6616,7 @@
66166616
} );
66176617

66186618
// Disallow links to admin, includes, and content, unless the matching allowed URL itself contains such a path.
6619-
if ( result && /\/wp-(admin|includes|content)(\/|$)/.test( urlParser.pathname.substring( matchedAllowedPath ? matchedAllowedPath.length : 0 ) ) ) {
6619+
if ( result && /\/wp-(admin|includes|content)(\/|$)/.test( urlParser.pathname.substring( matchedAllowedPath.length ) ) ) {
66206620
return null;
66216621
}
66226622

src/js/_enqueues/wp/customize/preview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
* @return {boolean} Is appropriate for changeset link.
282282
*/
283283
api.isLinkPreviewable = function isLinkPreviewable( element, options ) {
284-
var matchesAllowedUrl, matchedAllowedPath, parsedAllowedUrl, args, elementHost;
284+
var matchesAllowedUrl, matchedAllowedPath = '', parsedAllowedUrl, args, elementHost;
285285

286286
args = _.extend( {}, { allowAdminAjax: false }, options || {} );
287287

@@ -318,7 +318,7 @@
318318
}
319319

320320
// Disallow links to admin, includes, and content, unless the matching allowed URL itself contains such a path.
321-
if ( /\/wp-(admin|includes|content)(\/|$)/.test( element.pathname.substring( matchedAllowedPath ? matchedAllowedPath.length : 0 ) ) ) {
321+
if ( /\/wp-(admin|includes|content)(\/|$)/.test( element.pathname.substring( matchedAllowedPath.length ) ) ) {
322322
return false;
323323
}
324324

0 commit comments

Comments
 (0)