From 1e3eb0343d8b6084ec7ae41703875e9e1474b96c Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Fri, 28 Sep 2018 13:17:55 +0000
Subject: [PATCH] #4086 : on revient sur r24085 qui avait mal interprete la
 spec existante

---
 ecrire/inc/distant.php | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php
index 58a44adda9..96af93786a 100644
--- a/ecrire/inc/distant.php
+++ b/ecrire/inc/distant.php
@@ -1255,15 +1255,20 @@ function need_proxy($host, $http_proxy = null, $http_noproxy = null) {
 	$http_noproxy = str_replace("\r", " ", $http_noproxy);
 	$http_noproxy = " $http_noproxy ";
 	$domain = $host;
-	do {
-		if (strpos($http_noproxy, " $domain ") !== false) {
-			return '';
-		}
+	// si le domaine exact www.example.org est dans les exceptions
+	if (strpos($http_noproxy, " $domain ") !== false)
+		return '';
 
+	while (strpos($domain, '.') !== false) {
 		$domain = explode('.', $domain);
 		array_shift($domain);
 		$domain = implode('.', $domain);
-	} while (strpos($domain, '.') !== false);
+
+		// ou si un domaine parent commencant par un . est dans les exceptions (indiquant qu'il couvre tous les sous-domaines)
+		if (strpos($http_noproxy, " .$domain ") !== false) {
+			return '';
+		}
+	}
 
 	// ok c'est pas une exception
 	return $http_proxy;
-- 
GitLab