Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APC with standard ST terminator would break parser #101

Open
pda opened this issue Aug 10, 2022 · 0 comments
Open

APC with standard ST terminator would break parser #101

pda opened this issue Aug 10, 2022 · 0 comments

Comments

@pda
Copy link
Member

pda commented Aug 10, 2022

Buildkite uses ANSI Application Program Commands to insert timestamps into log streams. Technically APCs are terminated by “String Terminator” (ST; 0x9C), however in practice the non-standard 7-bit-clean “Bell” (BEL, 0x07) alternative tends to be used:

For historical reasons, Xterm can end the command with BEL as well as the standard ST
— https://en.wikipedia.org/wiki/ANSI_escape_code#OSC_(Operating_System_Command)_sequences

Our parser currently only supports BEL to terminate an APC. If an ST-terminated APC appeared in the log stream, our parser would miss everything until the next BEL or end-of-file.

This isn't an urgent issue, but maybe worth an easy fix one day.

Also described here as part of #99:

terminal-to-html/parser.go

Lines 141 to 157 in 384f24c

// handleApplicationProgramCommand is called for each character consumed while
// in MODE_APC, but does nothing until the APC is terminated with BEL (0x07).
//
// Technically an APC sequence is terminated by String Terminator (ST; 0x9C):
// https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_controls
//
// But:
// > For historical reasons, Xterm can end the command with BEL as well as the standard ST
// https://en.wikipedia.org/wiki/ANSI_escape_code#OSC_(Operating_System_Command)_sequences
//
// .. and this is how iTerm2 implements inline images:
// > ESC ] 1337 ; key = value ^G
// https://iterm2.com/documentation-images.html
//
// Buildkite's ansi timestamper does the same, and we don't _expect_ to be
// seeing any other APCs that could be ST-terminated... 🤞🏼
func (p *parser) handleApplicationProgramCommand(char rune) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant