diff --git a/app/Classes/Sock/SocketClient.php b/app/Classes/Sock/SocketClient.php index 421ccff..becf1c4 100644 --- a/app/Classes/Sock/SocketClient.php +++ b/app/Classes/Sock/SocketClient.php @@ -433,7 +433,34 @@ final class SocketClient { if ($flags !== MSG_PEEK) $this->rx_buf = substr($this->rx_buf,strlen($result)); - return $result; + // In case we are in Telnet Binary Mode + if ($this->iac_bin) { + if (self::DEBUG) + Log::debug(sprintf('%s:- Telnet IAC Binary Mode, looking for ff ff',self::LOGKEY)); + + // if the last char is ff, we need to get the next char + if (str_ends_with($result,"\xff")) { + // If we have it in our buffer, just get it + if ($this->rx_left) { + $result .= substr($this->rx_buf,0,1); + $this->rx_buf = substr($this->rx_buf,1); + + // Else put everything back into rx_buf, and increase len by 1 + } else { + $this->rx_buf = $result; + $len++; + $result = NULL; + } + } + + if (strlen($result) > 1) + $result = str_replace("\xff\xff","\xff",$result); + + if ($result) + return $result; + + } else + return $result; } if (self::DEBUG)