[icinga-checkins] icinga.org: icingaweb2/bugfix/ username-and-password-not-being-passed-in-navigation-item-urls-12133: Url: Do not try to set attributes in method fromPath if not needed

git at icinga.org git at icinga.org
Tue Oct 18 16:19:42 CEST 2016


Module: icingaweb2
Branch: bugfix/username-and-password-not-being-passed-in-navigation-item-urls-12133
Commit: 08719b0522fa4b84698114750b34fa91b1496d0e
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=08719b0522fa4b84698114750b34fa91b1496d0e

Author: Noah Hilverling <noah.hilverling at netways.de>
Date:   Tue Oct 18 16:13:37 2016 +0200

Url: Do not try to set attributes in method fromPath if not needed

refs #12133

---

 library/Icinga/Web/Url.php |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php
index 742002b..19310e6 100644
--- a/library/Icinga/Web/Url.php
+++ b/library/Icinga/Web/Url.php
@@ -214,20 +214,23 @@ class Url
         if (isset($urlParts['fragment'])) {
             $urlObject->setAnchor($urlParts['fragment']);
         }
-        if (isset($urlParts['host'])) {
-            $urlObject->setHost($urlParts['host']);
-        }
-        if (isset($urlParts['port'])) {
-            $urlObject->setPort($urlParts['port']);
-        }
-        if (isset($urlParts['scheme'])) {
-            $urlObject->setScheme($urlParts['scheme']);
-        }
-        if (isset($urlParts['user'])) {
-            $urlObject->setUsername($urlParts['user']);
-        }
-        if (isset($urlParts['pass'])) {
-            $urlObject->setPassword($urlParts['pass']);
+
+        if (isset($urlParts['user']) || $urlObject->isExternal()) {
+            if (isset($urlParts['user'])) {
+                $urlObject->setUsername($urlParts['user']);
+            }
+            if (isset($urlParts['host'])) {
+                $urlObject->setHost($urlParts['host']);
+            }
+            if (isset($urlParts['port'])) {
+                $urlObject->setPort($urlParts['port']);
+            }
+            if (isset($urlParts['scheme'])) {
+                $urlObject->setScheme($urlParts['scheme']);
+            }
+            if (isset($urlParts['pass'])) {
+                $urlObject->setPassword($urlParts['pass']);
+            }
         }
 
         $urlObject->setParams($params);



More information about the icinga-checkins mailing list