diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
index 3508bf5..05cd185 100644
|
|
|
4055 | 4055 | // ssl certs. |
4056 | 4056 | |
4057 | 4057 | previewer.add( 'previewUrl', params.previewUrl ).setter( function( to ) { |
4058 | | var result, urlParser, newPreviewUrl, schemeMatchingPreviewUrl, queryParams; |
| 4058 | var result = null, urlParser, queryParams, parsedAllowedUrl, parsedCandidateUrls = []; |
4059 | 4059 | urlParser = document.createElement( 'a' ); |
4060 | 4060 | urlParser.href = to; |
4061 | 4061 | |
… |
… |
|
4077 | 4077 | } |
4078 | 4078 | } |
4079 | 4079 | |
4080 | | newPreviewUrl = urlParser.href; |
4081 | | urlParser.protocol = previewer.scheme.get() + ':'; |
4082 | | schemeMatchingPreviewUrl = urlParser.href; |
| 4080 | parsedCandidateUrls.push( urlParser ); |
| 4081 | |
| 4082 | // Prepend list with URL that matches the scheme/protocol of the iframe. |
| 4083 | if ( previewer.scheme.get() + ':' !== urlParser.protocol ) { |
| 4084 | urlParser = document.createElement( 'a' ); |
| 4085 | urlParser.href = parsedCandidateUrls[0].href; |
| 4086 | urlParser.protocol = previewer.scheme.get() + ':'; |
| 4087 | parsedCandidateUrls.unshift( urlParser ); |
| 4088 | } |
4083 | 4089 | |
4084 | 4090 | // Attempt to match the URL to the control frame's scheme |
4085 | 4091 | // and check if it's allowed. If not, try the original URL. |
4086 | | $.each( [ schemeMatchingPreviewUrl, newPreviewUrl ], function( i, url ) { |
4087 | | $.each( previewer.allowedUrls, function( i, allowed ) { |
4088 | | var path; |
4089 | | |
4090 | | allowed = allowed.replace( /\/+$/, '' ); |
4091 | | path = url.replace( allowed, '' ); |
4092 | | |
4093 | | if ( 0 === url.indexOf( allowed ) && /^([/#?]|$)/.test( path ) ) { |
4094 | | result = url; |
4095 | | return false; |
| 4092 | parsedAllowedUrl = document.createElement( 'a' ); |
| 4093 | _.find( parsedCandidateUrls, function( parsedCandidateUrl ) { |
| 4094 | return ! _.isUndefined( _.find( previewer.allowedUrls, function( allowedUrl ) { |
| 4095 | parsedAllowedUrl.href = allowedUrl; |
| 4096 | if ( urlParser.protocol === parsedAllowedUrl.protocol && urlParser.host === parsedAllowedUrl.host && 0 === parsedAllowedUrl.pathname.indexOf( urlParser.pathname ) ) { |
| 4097 | result = parsedCandidateUrl.href; |
| 4098 | return true; |
4096 | 4099 | } |
4097 | | }); |
4098 | | if ( result ) { |
4099 | | return false; |
4100 | | } |
4101 | | }); |
| 4100 | } ) ); |
| 4101 | } ); |
4102 | 4102 | |
4103 | | // If we found a matching result, return it. If not, bail. |
4104 | | return result ? result : null; |
| 4103 | return result; |
4105 | 4104 | }); |
4106 | 4105 | |
4107 | 4106 | previewer.bind( 'ready', previewer.ready ); |
diff --git src/wp-includes/js/customize-base.js src/wp-includes/js/customize-base.js
index 11b868c..a8fa41d 100644
|
|
window.wp = window.wp || {}; |
654 | 654 | this.add( 'origin', this.url() ).link( this.url ).setter( function( to ) { |
655 | 655 | var urlParser = document.createElement( 'a' ); |
656 | 656 | urlParser.href = to; |
657 | | return urlParser.protocol + '//' + urlParser.hostname; |
| 657 | // Port stripping needed by IE since it adds to host but not to event.origin. |
| 658 | return urlParser.protocol + '//' + urlParser.host.replace( /:80$/, '' ); |
658 | 659 | }); |
659 | 660 | |
660 | 661 | // first add with no value |
diff --git src/wp-includes/js/customize-preview.js src/wp-includes/js/customize-preview.js
index 52de00d..f1bd852 100644
|
|
|
275 | 275 | * @param {HTMLAnchorElement|HTMLAreaElement} element Link element. |
276 | 276 | * @param {string} element.search Query string. |
277 | 277 | * @param {string} element.pathname Path. |
278 | | * @param {string} element.hostname Hostname. |
| 278 | * @param {string} element.host Host. |
279 | 279 | * @param {object} [options] |
280 | 280 | * @param {object} [options.allowAdminAjax=false] Allow admin-ajax.php requests. |
281 | 281 | * @returns {boolean} Is appropriate for changeset link. |
282 | 282 | */ |
283 | 283 | api.isLinkPreviewable = function isLinkPreviewable( element, options ) { |
284 | | var hasMatchingHost, urlParser, args; |
| 284 | var matchesAllowedUrl, parsedAllowedUrl, args; |
285 | 285 | |
286 | 286 | args = _.extend( {}, { allowAdminAjax: false }, options || {} ); |
287 | 287 | |
… |
… |
|
294 | 294 | return false; |
295 | 295 | } |
296 | 296 | |
297 | | urlParser = document.createElement( 'a' ); |
298 | | hasMatchingHost = ! _.isUndefined( _.find( api.settings.url.allowed, function( allowedUrl ) { |
299 | | urlParser.href = allowedUrl; |
300 | | if ( urlParser.hostname === element.hostname && urlParser.protocol === element.protocol ) { |
301 | | return true; |
302 | | } |
303 | | return false; |
| 297 | parsedAllowedUrl = document.createElement( 'a' ); |
| 298 | matchesAllowedUrl = ! _.isUndefined( _.find( api.settings.url.allowed, function( allowedUrl ) { |
| 299 | parsedAllowedUrl.href = allowedUrl; |
| 300 | return parsedAllowedUrl.protocol === element.protocol && parsedAllowedUrl.host === element.host && 0 === element.pathname.indexOf( parsedAllowedUrl.pathname ); |
304 | 301 | } ) ); |
305 | | if ( ! hasMatchingHost ) { |
| 302 | if ( ! matchesAllowedUrl ) { |
306 | 303 | return false; |
307 | 304 | } |
308 | 305 | |
… |
… |
|
331 | 328 | * @access protected |
332 | 329 | * |
333 | 330 | * @param {HTMLAnchorElement|HTMLAreaElement} element Link element. |
334 | | * @param {object} element.search Query string. |
| 331 | * @param {string} element.search Query string. |
| 332 | * @param {string} element.host Host. |
| 333 | * @param {string} element.protocol Protocol. |
335 | 334 | * @returns {void} |
336 | 335 | */ |
337 | 336 | api.prepareLinkPreview = function prepareLinkPreview( element ) { |
… |
… |
|
348 | 347 | } |
349 | 348 | |
350 | 349 | // Make sure links in preview use HTTPS if parent frame uses HTTPS. |
351 | | if ( 'https' === api.preview.scheme.get() && 'http:' === element.protocol && -1 !== api.settings.url.allowedHosts.indexOf( element.hostname ) ) { |
| 350 | if ( 'https' === api.preview.scheme.get() && 'http:' === element.protocol && -1 !== api.settings.url.allowedHosts.indexOf( element.host ) ) { |
352 | 351 | element.protocol = 'https:'; |
353 | 352 | } |
354 | 353 | |
… |
… |
|
496 | 495 | urlParser.href = form.action; |
497 | 496 | |
498 | 497 | // Make sure forms in preview use HTTPS if parent frame uses HTTPS. |
499 | | if ( 'https' === api.preview.scheme.get() && 'http:' === urlParser.protocol && -1 !== api.settings.url.allowedHosts.indexOf( urlParser.hostname ) ) { |
| 498 | if ( 'https' === api.preview.scheme.get() && 'http:' === urlParser.protocol && -1 !== api.settings.url.allowedHosts.indexOf( urlParser.host ) ) { |
500 | 499 | urlParser.protocol = 'https:'; |
501 | 500 | form.action = urlParser.href; |
502 | 501 | } |