Merge branch 'sb/describe-blob'
[gitweb.git] / imap-send.c
index 12cc4ea4c8ef9de6acf3116f478ed22e18054a98..36c7c1b4f6195b2d2f00013611a5d0aa96ecf408 100644 (file)
@@ -18,8 +18,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "cache.h"
@@ -1413,6 +1412,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
 {
        CURL *curl;
        struct strbuf path = STRBUF_INIT;
+       char *uri_encoded_folder;
 
        if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
                die("curl_global_init failed");
@@ -1430,7 +1430,12 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
        strbuf_addstr(&path, server.host);
        if (!path.len || path.buf[path.len - 1] != '/')
                strbuf_addch(&path, '/');
-       strbuf_addstr(&path, server.folder);
+
+       uri_encoded_folder = curl_easy_escape(curl, server.folder, 0);
+       if (!uri_encoded_folder)
+               die("failed to encode server folder");
+       strbuf_addstr(&path, uri_encoded_folder);
+       curl_free(uri_encoded_folder);
 
        curl_easy_setopt(curl, CURLOPT_URL, path.buf);
        strbuf_release(&path);