Re: [go-nuts] sanitize filename from post form upload

2017-08-30 Thread Tamás Gulácsi
Use if i := strings.LastIndexAny(fn, "/\\"); i >= 0 { fn = fn[i+1:] } As windows path uses different separator. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to g

Re: [go-nuts] sanitize filename from post form upload

2017-08-30 Thread David Arroyo
To sanitize a file path you can use https://golang.org/pkg/path/#Clean , but you probably want to use https://golang.org/pkg/path/#Base . The reason is that depending on the browser/client, you may get a path containing slashes, or you may get just the base filename. So it's better to just extract

[go-nuts] sanitize filename from post form upload

2017-08-30 Thread gocss
Is there go code to sanitize a filename [or filename(s) if ] when the handler is processing them so as to detect things such as ../ that might be buried within them ? Also is there a way to find out the full pathname? -- You received this message because you are subscribed to the Google Groups