From 0ecf3636073f47a249fd01a5c6450437d2a24487 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Wed, 20 Sep 2023 09:30:49 -0400 Subject: [PATCH 1/2] cmd/tclipd: handle untitled pastes better Fixes #29 Signed-off-by: Xe Iaso --- cmd/tclipd/main.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmd/tclipd/main.go b/cmd/tclipd/main.go index 1163b5d..2fe0533 100644 --- a/cmd/tclipd/main.go +++ b/cmd/tclipd/main.go @@ -126,6 +126,10 @@ LIMIT 5 return } + if jpi.Filename == "" { + jpi.Filename = "untitled" + } + jpis = append(jpis, jpi) } @@ -221,6 +225,10 @@ func (s *Server) TailnetSubmitPaste(w http.ResponseWriter, r *http.Request) { data := r.Form.Get("content") id := uuid.NewString() + if fname == "" { + fname = "untitled" + } + q := ` INSERT INTO pastes ( id @@ -322,6 +330,10 @@ OFFSET ?1 return } + if jpi.Filename == "" { + jpi.Filename = "untitled" + } + jpis = append(jpis, jpi) } @@ -502,6 +514,10 @@ WHERE p.id = ?1` return } + if fname == "" { + fname = "untitled" + } + lang := enry.GetLanguage(fname, []byte(data)) var rawHTML *template.HTML From 3134d240675396814e5949262d54f6ccb192b987 Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Wed, 20 Sep 2023 12:55:28 -0500 Subject: [PATCH 2/2] fix: typo --- cmd/tclipd/tmpl/publicindex.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/tclipd/tmpl/publicindex.html b/cmd/tclipd/tmpl/publicindex.html index b547295..b5bb4ea 100644 --- a/cmd/tclipd/tmpl/publicindex.html +++ b/cmd/tclipd/tmpl/publicindex.html @@ -1,6 +1,6 @@ {{template "header" .}}
-

Hello! You have connceted to a private pastebin run by a Tailscale user.

+

Hello! You have connected to a private pastebin run by a Tailscale user.

If this is your tailnet and you are not expecting to see this page, please connect to your tailnet and try your query again.