]> git.pond.sub.org Git - empserver/commitdiff
(ioq_gets): Support telnet line termination "\r\n". Previously,
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 11 Jun 2005 16:38:58 +0000 (16:38 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 11 Jun 2005 16:38:58 +0000 (16:38 +0000)
string input other than through parse() or getele() failed to strip
'\r', which could end up in ship names and such.
(getele): Code dealing with '\r' is now redundant, remove.  It ceased
to work in rev. 1.6 because input filtering replaces '\r' by '?'.

src/lib/gen/ioqueue.c
src/lib/subs/getele.c

index a792768686101bb79c625819783502bbfe52a0c3..41f68cda1beb409f6dde484e7edb2ad2e44e2ab2 100644 (file)
@@ -163,6 +163,9 @@ ioq_gets(struct ioqueue *ioq, s_char *buf, int cc)
        actual = nbytes;
        if (actual > cc - 1)
            actual = cc - 1;
+       /* telnet terminates lines with "\r\n", get rid of \r */
+       if (actual > 0 && buf[actual-1] == '\r')
+           actual--;
        buf[actual] = '\0';
        /* remove the newline too */
        removecc(ioq, nbytes + 1);
index 20c7e9e841f98e897da8e21659ecccf883ddb08b..0d1c4e2dcf30e8cda96d74448a3d355ab6990604 100644 (file)
@@ -75,9 +75,7 @@ getele(char *nation, char *buf /* buf is message text */)
            uprnf(buf);
            continue;
        }
-       if (buffer[0] == '.' && ((buffer[1] == 0)
-                                || (buffer[1] == '\n')
-                                || (buffer[1] == '\r')))
+       if (buffer[0] == '.' && buffer[1] == 0)
            break;
        len = strlen(buffer);
        buffer[len++] = '\n';
@@ -101,8 +99,7 @@ getele(char *nation, char *buf /* buf is message text */)
 static int
 tilde_escape(s_char *s, s_char c)
 {
-    if (s[0] == '~' && s[1] == c &&
-       ((s[2] == 0) || (s[2] == '\n') || (s[2] == '\r')))
+    if (s[0] == '~' && s[1] == c && s[2] == 0)
        return 1;
     return 0;
 }