Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
Fix a couple of issues with telegrams (beeps and HTML tags)
Browse files Browse the repository at this point in the history
I noticed that beep chars (ASCII 7), which come in some
telegrams (e.g. SBBSecho notices) were being printed as a box
glyph in the web UI. Strip those before emitting the telegram event.

I also noticed that some text was missing from some telegrams
(e.g. <user@addr> portion of email notices) - this was because
the <> chars weren't be html-entity-encoded. So now I'm using
html_encode() to HTML-entity encode the string (not the
white-space) and stripping the Ctrl-A codes here.

It would be kind of cool if the colors in the telegrams could
be retained/displayed, but html_encode sets the background of
the text to black, which doesn't look so hot with the current
theme and stuff. We might want to revisit that (e.g. not strip the
Ctrl-A chars here but rather let html_encode() tranlsate them to
HTML color sequences).

Another thing I noticed, if a telegram doesn't end in a CRLF, the
web UI doesn't automatically add/display a <br>. It probably should
(just in case). All telegrams should end in a CRLF, but you never
know.
  • Loading branch information
rswindell committed Jan 27, 2019
1 parent 5e6c079 commit 14329e1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web/lib/events/telegram.js
Expand Up @@ -6,7 +6,13 @@ function cycle() {
if (time() - last_run <= frequency) return;
last_run = time();
const tg = system.get_telegram(user.number);
if (tg !== null) emit({ event: 'telegram', data: JSON.stringify(tg) });
if (tg !== null) emit({ event: 'telegram'
, data: JSON.stringify(html_encode(tg.replace('\7', '').replace(/\1./g, '')
, /* ex-ascii */true
, /* white-space */false
, /* ansi */false
, /* ctrl_a */false))
});
}

this;

0 comments on commit 14329e1

Please sign in to comment.