~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH] msgstore_fs: Escape filenames with url.PathEscape

Details
Message ID
<20230409015114.3562338-1-cat@catcream.org>
DKIM signature
missing
Download raw message
Patch: +7 -2
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 (
	"context"
	"fmt"
	"io"
	"net/url"
	"os"
	"path/filepath"
	"sort"
@@ -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
			continue
		}

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

-- 
2.40.0
Details
Message ID
<ypk61qksnbzk.fsf@catcream.org>
In-Reply-To
<20230409015114.3562338-1-cat@catcream.org> (view parent)
DKIM signature
missing
Download raw message
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.
"/var/lib/#/soju/fs_store".

Will send an update later today.
Details
Message ID
<vgVdO9dWJt_XB-jcYlmnDWIeDzYJCoC4Qj1j0BTKTjZ17zDIPKXVb_S-38kiSvwWsnZIFQOJy6B0IYlvoIIx6jra35fOiZnVspk8-pprwfE=@emersion.fr>
In-Reply-To
<20230409015114.3562338-1-cat@catcream.org> (view parent)
DKIM signature
missing
Download raw message
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.
Reply to thread Export thread (mbox)