<html><head></head><body>Hi,<br><br>This looks plain wrong. CR is not a special character, or specifically a line ending in a Unix CLI (main use of RC interface) or in netcat-type tools (secondary use with in Unix or TCP socket modes).<br><br>Not to be confused with IETF protocols.<br>I'm not sure about the Telnet protocol specifically, but VLC RC and VLC Telnet interfaces are different modules.<br><br><div class="gmail_quote">Le 5 novembre 2020 13:01:49 GMT+02:00, Alexandre Janniaux <ajanni@videolabs.io> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">When using cli with --rc-host and --rc-fake-tty to control the cli<br>interface remotely, and using telnet to connect to it, \r\n is appended<br>at the end of each command. The code was removing the \n but not the \r<br>character. This refactor trimming into a function for clarity and uses<br>it to clean the beginning (additional spaces) and end (additional spaces<br>or line feed / carriage return) of the command.<hr> modules/control/cli/cli.c | 28 +++++++++++++++++++++++-----<br> 1 file changed, 23 insertions(+), 5 deletions(-)<br><br>diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c<br>index c741e7fcad..2095d9b8e8 100644<br>--- a/modules/control/cli/cli.c<br>+++ b/modules/control/cli/cli.c<br>@@ -287,11 +287,9 @@ static void UnknownCmd(intf_thread_t *intf, const char *const *args,<br>     (void) count;<br> }<br> <br>-static void Process(intf_thread_t *intf, const char *line)<br>+static void Process(intf_thread_t *intf, char *cmd)<br> {<br>     intf_sys_t *sys = intf->p_sys;<br>-    /* Skip heading spaces */<br>-    const char *cmd = line + strspn(line, " ");<br> <br>     if (*cmd == '\0')<br>         return; /* Ignore empty line */<br>@@ -349,6 +347,27 @@ error:      wordfree(&we);<br> #endif<br> }<br> <br>+static char *TrimLine(char *line)<br>+{<br>+    /* Skip heading spaces */<br>+    line = &line[strspn(line, " ")];<br>+<br>+    size_t length = strlen(line);<br>+<br>+    /* remove trailing CR/LF */<br>+    while (length > 0)<br>+    {<br>+        char c = line[length - 1];<br>+        if (c != '\r' && c != '\n' && c != ' ')<br>+            return line;<br>+<br>+        line[length - 1] = '\0';<br>+        length--;<br>+    }<br>+<br>+    return line;<br>+}<br>+<br> #ifndef _WIN32<br> static void *Run(void *data)<br> {<br>@@ -386,8 +405,7 @@ static void *Run(void *data)<br>         if (cmd != NULL)<br>         {<br>             int canc = vlc_savecancel();<br>-            if (cmd[0] != '\0')<br>-                cmd[strlen(cmd) - 1] = '\0'; /* remove trailing LF */<br>+            cmd = TrimLine(cmd);<br>             Process(intf, cmd);<br>             vlc_restorecancel(canc);<br>         }</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>