hannesm / jackline

minimalistic secure XMPP client in OCaml
BSD 2-Clause "Simplified" License
250 stars 20 forks source link

Messages starting with a "/" are interpreted as command #129

Open schoeke opened 8 years ago

schoeke commented 8 years ago

Wanted to send a file path, didn't go through.

Not a major bug, just annoying. ;)

cfcs commented 8 years ago

Hi, I considered letting "paths" through, but decided against it because it could be a misspelled command, which we want to avoid.

Slightly related PR + issue here:

I don't see an immediately clean solution for this (except to change the command prefix), but we could do something like looking for ^/[^ ]+/[^ ]+/ (at least three / characters without spaces in between. This would "solve" your issue for most paths, but I'm not sure if this is too hacky. I guess this is politics. @hannesm ?

hannesm commented 8 years ago

just write a space in front of the path... yes, it is annoying, but this is in-band signalling... (and no, regular expressions won't be included in jackline).. counting non-/ chars between multiple / chars could work (I've to sleep about that)...

sternenseemann commented 7 years ago

How about escaping \/ at the start of a input line as / (and \\ as \)?

hannesm commented 7 years ago

is it worth it? how often do you need to send / at the beginning of a line?

From cli/cli_input.ml:

                String.get input 0 = '/'
                (* copy-paste: treat as text if line starts with "/*" or "// " *)
                && not String.(length input >= 2 && get input 1 = '*')
                && not String.(length input >= 3 && sub input 1 2 = "/ ")
                && not String.(length input >= 3 && sub input 1 2 = "me")

--> // and /* (and /me) are already supported... everything else is considered to be a command...

sternenseemann commented 7 years ago

Not really that often, and most of the time using a dot or a space is fine. (Also this approach does not help you pasting a list of paths or likewise).

cfcs commented 7 years ago

I find that the only time I want to paste stuff with /, I'm pasting code. At that point it might be nicer to implement something like the shell script here-document. How about something like:

/uninterpreted <<EOFMARKER
To see your OTR fingerprint, do:
/fingerprint
EOFMARKER
cfcs commented 5 years ago

seems to be fixed for /* and // in https://github.com/hannesm/jackline/commit/e06a555ab34a9f8cb0cace7c222616365726304a