From 71d16d907d6950125c306a95f0c2daadd1714bcd Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Fri, 29 Jul 2011 14:52:45 -0400 Subject: [PATCH] - Patch #1174686 by ksenzee: overlay parent improperly opens child overlay on specific external links. --- modules/overlay/overlay-parent.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/overlay/overlay-parent.js b/modules/overlay/overlay-parent.js index 8f11df6694df..8010d01b2649 100644 --- a/modules/overlay/overlay-parent.js +++ b/modules/overlay/overlay-parent.js @@ -346,6 +346,10 @@ Drupal.overlay.setFocusBefore = function ($element, document) { * TRUE if the URL represents an administrative link, FALSE otherwise. */ Drupal.overlay.isAdminLink = function (url) { + if (Drupal.overlay.isExternalLink(url)) { + return false; + } + var path = this.getPath(url); // Turn the list of administrative paths into a regular expression. @@ -362,6 +366,20 @@ Drupal.overlay.isAdminLink = function (url) { return this.adminPathRegExp.exec(path) && !this.nonAdminPathRegExp.exec(path); }; +/** + * Determine whether a link is external to the site. + * + * @param url + * The url to be tested. + * + * @return boolean + * TRUE if the URL is external to the site, FALSE otherwise. + */ +Drupal.overlay.isExternalLink = function (url) { + var re = RegExp('^((f|ht)tps?:)?//(?!' + window.location.host + ')'); + return re.test(url); +}; + /** * Event handler: resizes overlay according to the size of the parent window. * -- GitLab