From 7e5dcb413de1ba853aee5a10660f71ab84aa3661 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Fri, 8 Dec 2023 15:44:34 -0800
Subject: [PATCH] Trim all control chars off the ends of lines

This solves the problem of detecting a Synchronet (for OS/2) BBS at
telnet://wyseguybbs.mywire.org:2300

That system responds with some control characters (NULs and ^Cs)
before the initial welcome banner, so just strip those out.
---
 exec/load/termcapture_lib.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/exec/load/termcapture_lib.js b/exec/load/termcapture_lib.js
index 6b3eb62d86..1dd3bc9cfd 100644
--- a/exec/load/termcapture_lib.js
+++ b/exec/load/termcapture_lib.js
@@ -120,7 +120,7 @@ function capture()
             lines.length = 0;
             curline="";
         } else if(char=='\n') {
-            if(curline.length && curline.charAt(curline.length-1)=='\r')
+            while(curline.length && curline.charCodeAt(curline.length-1) < ascii(' '))
                 curline = curline.substring(0,curline.length-1);
             lines.push(curline);
             log(LOG_DEBUG, format("Captured %u lines (last: %u bytes)", lines.length, curline.length));
-- 
GitLab