Improve renaming of files for http-uplad

Characters get replaced by `_` now instead of being removed and
`-`, `_`, `.` and `+` won't be removed anymore. (Thx Holger Weiß)
v0.1
Martin Dosch 2 years ago
parent fa1356d05d
commit 2c2a576152

@ -2,7 +2,7 @@
## [Unreleased]
### Changed
- Rename files to use alpha numerical file name before uploading. Workaround for https://github.com/mattn/go-xmpp/issues/132
- Rename files to use a limited character set (alpha numerical and some extra characters) file name before uploading. Workaround for https://github.com/mattn/go-xmpp/issues/132
## [v0.1.2]
### Changed

@ -134,11 +134,11 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
fileName := filepath.Base(filePath)
// Just use alphanumerical characters for now to work around
// https://github.com/mattn/go-xmpp/issues/132
reg, err := regexp.Compile("[^a-zA-Z0-9.]+")
reg, err := regexp.Compile(`[^a-zA-Z0-9\+\-\_\.]+`)
if err != nil {
log.Fatal(err)
}
fileNameEscaped := reg.ReplaceAllString(fileName, "")
fileNameEscaped := reg.ReplaceAllString(fileName, "_")
//var fileNameEscaped bytes.Buffer
//xml.Escape(&fileNameEscaped, []byte(fileName))

Loading…
Cancel
Save