Escape slashes in room IDs in cache file names
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
sync "github.com/sasha-s/go-deadlock"
|
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 {
|
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 {
|
func (cache *RoomCache) Load(roomID id.RoomID) *Room {
|
||||||
|
Reference in New Issue
Block a user