# HG changeset patch
# Parent 58ed3d69156d921bb7008c2eb823c53f5a31b3b5
Fixes 16267 : Strip // from start of relative urls and handle case when context is / in classic popup javascript

diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
@@ -98,7 +98,9 @@
     OB.ActionButton.executingProcess = null;
     
     if (newWindow) {
-      var contextURL = location.href.substr(0, location.href.indexOf(OB.Application.contextUrl) + OB.Application.contextUrl.length);
+      var contextURL = location.protocol +"//"
+                        + location.host
+                        + location.pathname.substr(0, location.pathname.indexOf(OB.Application.contextUrl) + OB.Application.contextUrl.length);
       
       if (newWindow.indexOf(contextURL) !== -1){
         newWindow = newWindow.substr(contextURL.length);
diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-compatibility.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-compatibility.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-compatibility.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-compatibility.js
@@ -334,6 +334,10 @@
         if (showCloseControl !== false) {
           showCloseControl = true;
         }
+        if (url.indexOf("//") === 0) {
+          // Double slash at start of relative URL only keeps scheme, not server
+          url = url.substring(1);
+        }
         var cPopup = isc.OBClassicPopup.create({
           ID: name + '_' + cobcomp.Popup.secString,
           width: width,
diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-popup.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-popup.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-popup.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-popup.js
@@ -43,7 +43,11 @@
     }
     if(this.obManualURL !== '') {
       contentsURL = OB.Application.contextUrl + this.obManualURL + '?Command=' + this.command;
-//      contentsURL = this.appURL + urlCharacter + 'url=' + this.obManualURL + '&noprefs=true&Command=' + this.command + '&hideMenu=true';
+      if(contentsURL.indexOf("//") === 0 ) {
+        // Double slash at start of relative URL only keeps scheme, not server
+        contentsURL = contentsURL.substring(1);
+      }
+    //      contentsURL = this.appURL + urlCharacter + 'url=' + this.obManualURL + '&noprefs=true&Command=' + this.command + '&hideMenu=true';
     } else {
       contentsURL = this.appURL + urlCharacter + 'Command=' + this.command + '&noprefs=true&tabId=' + this.tabId + '&hideMenu=true';
     }
