From ec2b8d0fee1ea9c9907c5f0f74c974928e7eae8e Mon Sep 17 00:00:00 2001 From: Mikael Fangel <34864484+MikaelFangel@users.noreply.github.com> Date: Mon, 13 Mar 2023 21:35:29 +0100 Subject: [PATCH] removed bksp from stdin (#306) * removed bksp from stdin --------- Co-authored-by: Maas Lalani --- pager/command.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pager/command.go b/pager/command.go index 0b4fd45..47f6182 100644 --- a/pager/command.go +++ b/pager/command.go @@ -2,6 +2,7 @@ package pager import ( "fmt" + "regexp" "github.com/alecthomas/kong" "github.com/charmbracelet/bubbles/viewport" @@ -22,7 +23,9 @@ func (o Options) Run() error { return fmt.Errorf("unable to read stdin") } if stdin != "" { - o.Content = stdin + // Sanitize the input from stdin by removing backspace sequences. + backspace := regexp.MustCompile(".\x08") + o.Content = backspace.ReplaceAllString(stdin, "") } else { return fmt.Errorf("provide some content to display") }