From 56cc42b7522c46d616c88db0a6261578b121dc9d Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Tue, 15 Oct 2019 16:12:01 +0200
Subject: [PATCH] storage/curl: use MapUTF8() to reuse existing escaping code

Commit 29f78b18b1d continued.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/662
---
 NEWS                                | 1 +
 src/storage/plugins/CurlStorage.cxx | 9 ++-------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 276fe027d..c0d175464 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 ver 0.21.16 (not yet released)
 * storage
   - curl: request the "resourcetype" property to fix database update
+  - curl: URL-encode more paths
 * update
   - fix crash when music_directory is not a directory
 * fix build with iconv() instead of ICU
diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx
index 8f2dea64f..3790cc5a8 100644
--- a/src/storage/plugins/CurlStorage.cxx
+++ b/src/storage/plugins/CurlStorage.cxx
@@ -445,9 +445,7 @@ CurlStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow)
 {
 	// TODO: escape the given URI
 
-	std::string uri = base;
-	uri += uri_utf8;
-
+	const auto uri = MapUTF8(uri_utf8);
 	return HttpGetInfoOperation(*curl, uri.c_str()).Perform();
 }
 
@@ -537,10 +535,7 @@ protected:
 std::unique_ptr<StorageDirectoryReader>
 CurlStorage::OpenDirectory(const char *uri_utf8)
 {
-	// TODO: escape the given URI
-
-	std::string uri = base;
-	uri += uri_utf8;
+	std::string uri = MapUTF8(uri_utf8);
 
 	/* collection URIs must end with a slash */
 	if (uri.back() != '/')