Escape slashes in room IDs in cache file names

This commit is contained in:
Tulir Asokan 2021-08-02 21:45:38 +03:00
parent 2008d3755e
commit 8ad2aa4e1a

View File

@ -22,6 +22,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"
sync "github.com/sasha-s/go-deadlock"
@ -268,7 +269,8 @@ func (cache *RoomCache) Put(room *Room) {
}
func (cache *RoomCache) roomPath(roomID id.RoomID) string {
return filepath.Join(cache.directory, string(roomID)+".gob.gz")
escapedRoomID := strings.ReplaceAll(strings.ReplaceAll(string(roomID), "%", "%25"), "/", "%2F")
return filepath.Join(cache.directory, escapedRoomID+".gob.gz")
}
func (cache *RoomCache) Load(roomID id.RoomID) *Room {