From fde416aa25519318c19ade3e3a741b4394d51b31 Mon Sep 17 00:00:00 2001
From: FSMPI Admin-Team <admin@fsmpi.rwth-aachen.de>
Date: Tue, 4 Apr 2017 01:05:07 +0200
Subject: [PATCH] Correctly handle whitespace in etherpad identifiers

---
 utils.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/utils.py b/utils.py
index d4ce449..1ac0c4d 100644
--- a/utils.py
+++ b/utils.py
@@ -108,15 +108,17 @@ def get_first_unused_int(numbers):
             return linear
     return highest + 1
 
+def normalize_pad(pad):
+    return pad.replace(" ", "_")
 def get_etherpad_url(pad):
-    return "{}/p/{}".format(config.ETHERPAD_URL, pad)
+    return "{}/p/{}".format(config.ETHERPAD_URL, normalize_pad(pad))
 def get_etherpad_export_url(pad):
-    return "{}/p/{}/export/txt".format(config.ETHERPAD_URL, pad)
+    return "{}/p/{}/export/txt".format(config.ETHERPAD_URL, normalize_pad(pad))
 def get_etherpad_import_url(pad):
-    return "{}/p/{}/import".format(config.ETHERPAD_URL, pad)
+    return "{}/p/{}/import".format(config.ETHERPAD_URL, normalize_pad(pad))
 
 def get_etherpad_text(pad):
-    req = requests.get("{}/p/{}/export/txt".format(config.ETHERPAD_URL, pad))
+    req = requests.get(get_etherpad_export_url(pad))
     return req.text
 
 def set_etherpad_text(pad, text, only_if_default=True):
-- 
GitLab