From 3624fd95101efb9186d2144b03f9d2c9925f5652 Mon Sep 17 00:00:00 2001 From: sloum Date: Sun, 1 Nov 2020 06:45:11 -0800 Subject: [PATCH 1/2] Minor fix to how we verify hostnames --- gemini/gemini.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gemini/gemini.go b/gemini/gemini.go index 526aca6..482cfae 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -78,7 +78,7 @@ func (t *TofuDigest) Match(host, localCert string, cState *tls.ConnectionState) return fmt.Errorf("EXP") } - if err := cert.VerifyHostname(host); err != nil { + if err := cert.VerifyHostname(host); err != nil && cert.Subject.CommonName != host { return fmt.Errorf("Certificate error: %s", err) } @@ -107,7 +107,7 @@ func (t *TofuDigest) newCert(host string, cState *tls.ConnectionState) error { continue } - if err := cert.VerifyHostname(host); err != nil { + if err := cert.VerifyHostname(host); err != nil && cert.Subject.CommonName != host { reasons.WriteString(fmt.Sprintf("Cert [%d] hostname does not match", index+1)) continue } From 388218a5b677ee1c798e6f94c6fd1bbbe2e306e5 Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 5 Nov 2020 21:17:19 +1100 Subject: [PATCH 2/2] Initial support for some unicode line endings --- page.go | 4 ++-- page_test.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/page.go b/page.go index ad44ab2..890f018 100644 --- a/page.go +++ b/page.go @@ -91,8 +91,8 @@ func (p *Page) WrapContent(width int, color bool) { } continue } - if ch == '\n' { - content.WriteRune(ch) + if ch == '\n' || ch == '\u0085' || ch == '\u2028' || ch == '\u2029' { + content.WriteRune('\n') counter = 0 } else if ch == '\t' { if counter+4 < width { diff --git a/page_test.go b/page_test.go index ef41a80..b5e8f94 100644 --- a/page_test.go +++ b/page_test.go @@ -61,6 +61,26 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) { false, }, }, + { + "Unicode line endings that should not wrap", + "LF\u000A" + + "CR+LF\u000D\u000A" + + "NEL\u0085" + + "LS\u2028" + + "PS\u2029", + []string{ + "LF", + "CR+LF", + "NEL", + "LS", + "PS", + "", + }, + args{ + 10, + false, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {