Skip to content

Commit

Permalink
Added PGP meta filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Jan 20, 2022
1 parent e3740cc commit 63b4ce4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tui/mainscreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,19 @@ func(mainscreen *Mainscreen) selectHandler(item string)(func(int, string, string
}

func(mainscreen *Mainscreen) renderPreview(article *models.Article) {
m := regexp.MustCompile(`(?m)^> (.*)\n`)
body := m.ReplaceAllString(article.Body, "[gray]> $1[-]\n")
var m *regexp.Regexp
body := article.Body

// Removing GPG/PGP stuff until there is a prober validation for it
m = regexp.MustCompile(`(?m)^(> ){0,1}-----BEGIN PGP SIGNED MESSAGE-----\n(> ){0,1}Hash:(.*)(\n( >){0,1}){1,2}`)
body = m.ReplaceAllString(body, "")

m = regexp.MustCompile(`(?sm)^(> ){0,1}-----BEGIN PGP SIGNATURE-----.*-----END PGP SIGNATURE-----$`)
body = m.ReplaceAllString(body, "")
// End GPG/PGP stuff

m = regexp.MustCompile(`(?m)^> (.*)\n`)
body = m.ReplaceAllString(body, "[gray]> $1[-]\n")

mainscreen.Preview.SetText(fmt.Sprintf(
"[gray]Date:[-] [darkgray]%s[-]\n[gray]Newsgroup:[-] [darkgray]%s[-]\n\n\n%s",
Expand Down

0 comments on commit 63b4ce4

Please sign in to comment.