shithub: 9pro

Download patch

ref: a82e8034cd0f44560eeb91269e992399700fb86f
parent: a0194e7c865a0d0b02fc51190fdc5c975c204c8c
author: Sigrid Haflínudóttir <[email protected]>
date: Sat Aug 8 04:07:53 EDT 2020

strip control chars

--- a/9gc.c
+++ b/9gc.c
@@ -153,6 +153,19 @@
 }
 
 static void
+output(uint8_t *d, int sz)
+{
+	int i, j;
+
+	for (i = j = 0; i < sz; i++) {
+		d[j] = d[i];
+		if (d[j] > 31 || d[j] == '\t' || d[j] == '\n')
+			j++;
+	}
+	write(1, d, j);
+}
+
+static void
 ctxchatR(C9ctx *ctx, C9r *r)
 {
 	C9aux *a;
@@ -172,7 +185,7 @@
 
 	case Rread:
 		if (chatoff >= skipuntil)
-			write(1, r->read.data, r->read.size);
+			output(r->read.data, r->read.size);
 		chatoff += r->read.size;
 		/* fallthrough */
 	case Ropen: