telnet-client
telnet-client copied to clipboard
Error prompt not detected if prompt is set to empty string
If $prompt
is set to an empty string (""
) and $promptError
is set as non-empty (eg. "ERROR"
) then any error condition is never detected.
Using the example from the README, this is what would happen:
Graze\TelnetClient\TelnetResponse {#188
#isError: false
#responseText: "I'm sorry, Dave. I'm afraid I can't do that\nERROR"
#promptMatches: array:1 [
0 => ""
]
}
The reason that this happens is that prompt checking (getResponse()
in Graze\TelnetClient\TelnetClient
) happens before error checking. In the case of an empty prompt it always matches and so the error prompt check never happens.
Some thoughts on fixes:
- Change the ordering such that error prompt checking happens first.
- Don't attempt any matching if a prompt is an empty string
(Note that I didn't actually test out what the exact response of that command would be. It's an educated guess based on my reading of the code.)