From 4493974816f3365db387d1ee2ef5692b50dcc5cc Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Thu, 11 Feb 2021 11:37:05 +0100
Subject: [PATCH] Fix #4612 : urlencoder a la volee les chars utf dans les urls

---
 ecrire/inc/distant.php | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php
index d78bd4a447..0eaba2996a 100644
--- a/ecrire/inc/distant.php
+++ b/ecrire/inc/distant.php
@@ -355,6 +355,8 @@ function url_to_ascii($url_idn) {
 			$url_idn = explode($host, $url_idn, 2);
 			$url_idn = implode($host_ascii, $url_idn);
 		}
+		// et on urlencode les char utf si besoin dans le path
+		$url_idn = preg_replace_callback('/[^\x20-\x7f]/', function($match) { return urlencode($match[0]); }, $url_idn);
 	}
 
 	return $url_idn;
-- 
GitLab