From 15d46556742ba43d0b59c1ba3bb8e525604b30ec Mon Sep 17 00:00:00 2001 From: Farhad Makiabady Date: Tue, 9 Oct 2018 12:06:06 -0600 Subject: [PATCH 1/3] changed validURL to validURI --- interfacer/src/browsh/browsh.go | 8 ++++---- interfacer/src/browsh/comms.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/interfacer/src/browsh/browsh.go b/interfacer/src/browsh/browsh.go index 2f18af0c..e65dd05f 100644 --- a/interfacer/src/browsh/browsh.go +++ b/interfacer/src/browsh/browsh.go @@ -192,17 +192,17 @@ func ttyEntry() { // MainEntry decides between running Browsh as a CLI app or as an HTTP web server func MainEntry() { pflag.Parse() - // validURL contains array of valid user inputted links. - var validURL []string + // validURI contains array of valid user inputted links. + var validURI []string if pflag.NArg() != 0 { for i := 0; i < len(pflag.Args()); i++ { u, _ := url.ParseRequestURI(pflag.Args()[i]) if u != nil { - validURL = append(validURL, pflag.Args()[i]) + validURI = append(validURI, pflag.Args()[i]) } } } - viper.SetDefault("validURL", validURL) + viper.SetDefault("validURI", validURI) Initialise() if viper.GetBool("version") { println(browshVersion) diff --git a/interfacer/src/browsh/comms.go b/interfacer/src/browsh/comms.go index 4199eca3..0d207183 100644 --- a/interfacer/src/browsh/comms.go +++ b/interfacer/src/browsh/comms.go @@ -147,12 +147,12 @@ func webSocketServer(w http.ResponseWriter, r *http.Request) { } // For some reason, using Firefox's CLI arg `--url https://google.com` doesn't consistently // work. So we do it here instead. - validURL := viper.GetStringSlice("validURL") - if len(validURL) == 0 { + validURI := viper.GetStringSlice("validURI") + if len(validURI) == 0 { sendMessageToWebExtension("/new_tab," + viper.GetString("startup-url")) } else { - for i := 0; i < len(validURL); i++ { - sendMessageToWebExtension("/new_tab," + validURL[i]) + for i := 0; i < len(validURI); i++ { + sendMessageToWebExtension("/new_tab," + validURI[i]) } } } From 89d1b5f940e2135ec78dc10409cd91ac9ebe3f96 Mon Sep 17 00:00:00 2001 From: Farhad Makiabady Date: Tue, 9 Oct 2018 12:23:44 -0600 Subject: [PATCH 2/3] moved no flag parsing into its own function --- interfacer/src/browsh/browsh.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/interfacer/src/browsh/browsh.go b/interfacer/src/browsh/browsh.go index e65dd05f..39998280 100644 --- a/interfacer/src/browsh/browsh.go +++ b/interfacer/src/browsh/browsh.go @@ -189,9 +189,7 @@ func ttyEntry() { TTYStart(realScreen) } -// MainEntry decides between running Browsh as a CLI app or as an HTTP web server -func MainEntry() { - pflag.Parse() +func noFlagParse() { // validURI contains array of valid user inputted links. var validURI []string if pflag.NArg() != 0 { @@ -203,6 +201,12 @@ func MainEntry() { } } viper.SetDefault("validURI", validURI) +} + +// MainEntry decides between running Browsh as a CLI app or as an HTTP web server +func MainEntry() { + pflag.Parse() + noFlagParse() Initialise() if viper.GetBool("version") { println(browshVersion) From 67073f7a2bbbde4d644b870994adf881aa299743 Mon Sep 17 00:00:00 2001 From: Farhad Makiabady Date: Wed, 10 Oct 2018 15:06:48 -0600 Subject: [PATCH 3/3] removed URL validation --- interfacer/src/browsh/browsh.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/interfacer/src/browsh/browsh.go b/interfacer/src/browsh/browsh.go index 39998280..e7e1b1c8 100644 --- a/interfacer/src/browsh/browsh.go +++ b/interfacer/src/browsh/browsh.go @@ -4,7 +4,6 @@ import ( "encoding/base64" "fmt" "io/ioutil" - "net/url" "os" "os/exec" "path/filepath" @@ -194,10 +193,7 @@ func noFlagParse() { var validURI []string if pflag.NArg() != 0 { for i := 0; i < len(pflag.Args()); i++ { - u, _ := url.ParseRequestURI(pflag.Args()[i]) - if u != nil { - validURI = append(validURI, pflag.Args()[i]) - } + validURI = append(validURI, pflag.Args()[i]) } } viper.SetDefault("validURI", validURI)