dparrish / libcli

Libcli provides a shared library for including a Cisco-like command-line interface into other software. It's a telnet interface which supports command-line editing, history, authentication and callbacks for a user-definable function tree.
https://dparrish.com/link/libcli
GNU Lesser General Public License v2.1
289 stars 143 forks source link

Make libcli 'case sensitive' for handling completors #90

Closed RobSanders closed 6 months ago

RobSanders commented 6 months ago

Currently libcli is basically doing case insensitive checks for all command lookups and '' or '' actions, as well as for the completors. Specific to commands you cannot currently have a command "delete" and one "DELETE" within the same mode. If the commands were 'Delete' and 'declutter' for example, the command name will be correctly display and selected if enough case insensitive characters were entered to resolve one or the other.

For completors it appears to be a bit different. If your set of potential completors could contain entries that differ only in case (one example being a completor for selecting a single file from a Linux directory) if there are entries that differ only in case, then using tab completion you will only be able to get one or the other, depending on which one appears first in the completor entries.

A possible quick fix is to change the strncasecmp() command near line 1506 in libcli.c (1.10.7 version) to be a strncmp(). This makes the main 'see where entries differ' be case sensitive.

Initial testing this did not seem to break anything, and preserves the current 'commands are case insensitive' behavior.

RobSanders commented 6 months ago

Issue merged to staging 1.10.8