From 2a395008fa0d060c24a5e159d50f73d33d73a820 Mon Sep 17 00:00:00 2001 From: makeworld Date: Mon, 29 Jun 2020 14:25:25 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Raise=20Error=20modal=20when=20i?= =?UTF-8?q?nput=20makes=20URL=20too=20long=20-=20fixes=20#25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + NOTES.md | 6 ++++-- display/private.go | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0f91b..ba021ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Alt-Left and Alt-Right for history navigation (#23) - You can type `..` in the bottom bar to go up a directory in the URL (#21) +- Error popup for when input string would result in a too long out-of-spec URL (#25) ### Changed - Bottom bar now says `URL/Num./Search: ` when space is pressed diff --git a/NOTES.md b/NOTES.md index a5335c1..ebd28f3 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,7 +1,9 @@ # Notes -- All the maps and stuff could be replaced with a `tab` struct -- And then just one single map of tab number to `tab` +- Simplify into one struct + - All the maps and stuff could be replaced with a `tab` struct + - And then just one single map of tab number to `tab` + - URL for each tab should not be stored as a string - in the current code there's lots of reparsing the URL ## Bugs - Wrapping messes up on brackets diff --git a/display/private.go b/display/private.go index ff06092..2cde509 100644 --- a/display/private.go +++ b/display/private.go @@ -288,6 +288,11 @@ func handleURL(u string) (string, bool) { // Make another request with the query string added // + chars are replaced because PathEscape doesn't do that parsed.RawQuery = pathEscape(userInput) + if len(parsed.String()) > 1024 { + // 1024 is the max size for URLs in the spec + Error("Input Error", "URL for that input would be too long.") + return "", false + } return handleURL(parsed.String()) } return "", false