gomuks icon indicating copy to clipboard operation
gomuks copied to clipboard

Command.RawArgs has surrounding whitespace trimmed

Open FiskFan1999 opened this issue 2 years ago • 1 comments

Hello tulir and gomuks contributors,

This PR trims the extreme left and right whitespace around command.RawArgs, which, among other things, is used as the path of the file in the /upload command. I found the following behavior when using gomuks in macos: in the terminal, you're allowed to drag and drop a file from the desktop or "finder", and terminal pastes the absolute path, followed by a space. This caused gomuks on the latest master branch to throw a file not found exception, while taking care to delete the extra space character succeeds of course (steps to reproduce: in any room, type /upload /correct/path/to/file followed by a space, . This should fail and throw a "file not found" error).

strings.TrimSpace only trims space on the extreme left and right. Since strings.Fields also trims this whitespace as well as whitespace between the words I think it is reasonable to trim whitespace for command.RawArgs. As far as I can tell, this doesn't break any other commands that RawArgs is used for.

Thank you, am looking forward to your input on this.

FiskFan1999 avatar Jun 07 '22 03:06 FiskFan1999

@tulir: Anything else needed to merge this in?

pataquets avatar Aug 03 '22 17:08 pataquets