diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index c037ef991836f17a5a4356a9e16b8cceb7623284..419a2ca8987bde00d66ad34122295ce27751f47a 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -345,7 +345,7 @@ class Simple
             $returnTo = $httpUtils->getSelfURL();
         }
 
-        $logout = Module::getModuleURL('core/logout/' . $this->authSource, [
+        $logout = Module::getModuleURL('core/logout/' . urlencode($this->authSource), [
             'ReturnTo' => $returnTo,
         ]);