msgstore_fs: Escape filenames with url.PathEscape v1 PROPOSED

Alfred Persson Forsberg: 1
 msgstore_fs: Escape filenames with url.PathEscape

 1 files changed, 7 insertions(+), 2 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/40240/mbox | git am -3
Learn more about email & git

[PATCH] msgstore_fs: Escape filenames with url.PathEscape Export this patch

Previously, channels with characters like '/' would just get replaced
with '-'. This caused soju+gamja to act very weirdly, like showing
two channels instead of one.

Note: This is my first time contributing to a Go project, please
review this carefully. Seems to work fine for me while testing with
chathistorysync and senpai.

Closes: https://todo.sr.ht/~emersion/soju/208
Signed-off-by: Alfred Persson Forsberg <cat@catcream.org>
 msgstore/fs.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/msgstore/fs.go b/msgstore/fs.go
index 00f0e00..a6cfa67 100644
--- a/msgstore/fs.go
+++ b/msgstore/fs.go
@@ -5,6 +5,7 @@ import (
@@ -30,7 +31,7 @@ func EscapeFilename(unsafe string) (safe string) {
	} else if unsafe == ".." {
		return "--"
	} else {
		return strings.NewReplacer("/", "-", "\\", "-").Replace(unsafe)
		return url.PathEscape(unsafe)

@@ -492,8 +493,12 @@ func (ms *fsMessageStore) ListTargets(ctx context.Context, network *database.Net

		targetName, err := url.PathUnescape(target)
		if err != nil {
			return nil, err
		targets = append(targets, ChatHistoryTarget{
			Name:          target,
			Name:          targetName,
			LatestMessage: t,

Probably better to make a separate EscapeFilename function for
channels, and then unescape the channel name for CHATHISTORY like I
currently do.

This will escape the whole path which won't work with for ex.

Will send an update later today.
I've been holding off this patch because it behaves differently than
ZNC, which we inherit the log format from. ZNC escapes with "-" as well.