From b2a35c090dc2d17c7ab034c6869f68f8f7d0a846 Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Mon, 20 Nov 2017 01:08:26 +0000 Subject: [PATCH 1/4] excmd: fix wikipedia search url --- src/excmds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/excmds.ts b/src/excmds.ts index 27fdb056..8feddd12 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -73,7 +73,7 @@ const SEARCH_URLS = new Map([ ["duckduckgo","https://duckduckgo.com/?q="], ["yahoo","https://search.yahoo.com/search?p="], ["twitter","https://twitter.com/search?q="], - ["wikipedia","https://en.wikipedia.org/wiki/"], + ["wikipedia","https://en.wikipedia.org/wiki/Special:Search/"], ["youtube","https://www.youtube.com/results?search_query="], ["amazon","https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords="], ["amazonuk","https://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords="], From ba99fdaf80b3ddd93f2ffb1712d6ba7e242adf11 Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Mon, 20 Nov 2017 01:11:38 +0000 Subject: [PATCH 2/4] excmd: x-www-form-urlencode query strings Fixes #83. --- src/excmds.ts | 52 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/src/excmds.ts b/src/excmds.ts index 8feddd12..c2ab4638 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -84,21 +84,53 @@ function hasScheme(uri: string) { return uri.match(/^([\w-]+):/) } +/** We use this over encodeURIComponent so that '+'s in non queries are not encoded. */ +/** @hidden */ +function searchURL(provider: string, query: string) { + if (SEARCH_URLS.has(provider)) { + const url = new URL(SEARCH_URLS.get(provider) + query) + // URL constructor doesn't convert +s because they're valid literals in + // the standard it adheres to. But they are special characters in + // x-www-form-urlencoded and e.g. google excepts query parameters in + // that format. + url.search = url.search.replace(/\+/g, '%2B') + return url + } else { + throw new TypeError(`Unknown provider: '${provider}'`) + } +} + /** If maybeURI doesn't have a schema, affix http:// */ /** @hidden */ -function forceURI(maybeURI: string) { - if (hasScheme(maybeURI)) { - return maybeURI +function forceURI(maybeURI: string): string { + try { + return new URL(maybeURI).href + } catch (e) { + if (e.name !== 'TypeError') throw e } - let urlarr = maybeURI.split(" ") - if (SEARCH_URLS.get(urlarr[0]) != null){ - return SEARCH_URLS.get(urlarr[0]) + urlarr.slice(1,urlarr.length).join(" ") - } else if (urlarr[0].includes('.')) { - return "http://" + maybeURI - } else { - return SEARCH_URLS.get("google") + maybeURI + // Else if search keyword: + try { + const args = maybeURI.split(' ') + return searchURL(args[0], args.slice(1).join(' ')).href + } catch (e) { + console.log(e) + if (e.name !== 'TypeError') throw e } + + // Else if it's a domain or something + try { + const url = new URL('http://' + maybeURI) + // Ignore unlikely domains + if (url.hostname.includes('.') || url.port || url.password) { + return url.href + } + } catch (e) { + if (e.name !== 'TypeError') throw e + } + + // Else search google + return searchURL('google', maybeURI).href } /** @hidden */ From be7b304212b6c1b4acc17dc9ef1db82923bbf67e Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Mon, 20 Nov 2017 01:31:47 +0000 Subject: [PATCH 3/4] cmdline: don't store history for :winopen -private Component of #53. --- src/commandline_frame.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/commandline_frame.ts b/src/commandline_frame.ts index db9a40d4..cc6c75a6 100644 --- a/src/commandline_frame.ts +++ b/src/commandline_frame.ts @@ -101,10 +101,16 @@ function process() { console.log(clInput.value) sendExstr("hidecmdline") sendExstr(clInput.value) - if (! browser.extension.inIncognitoContext) { + + // Save non-secret commandlines to the history. + const [func,...args] = clInput.value.trim().split(/\s+/) + if (! browser.extension.inIncognitoContext && + ! (func === 'winopen' && args[0] === '-private') + ) { state.cmdHistory = state.cmdHistory.concat([clInput.value]) } console.log(state.cmdHistory) + completions.innerHTML = "" clInput.value = "" cmdline_history_position = 0 From 538aab80bc21c3d0f1c84676cb89b0bfab073a1b Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Mon, 20 Nov 2017 01:58:26 +0000 Subject: [PATCH 4/4] release: 1.3.1 --- src/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest.json b/src/manifest.json index 8fae2bb6..9f52a8ac 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Tridactyl", - "version": "1.3.0", + "version": "1.3.1", "icons": { "64": "static/logo/Tridactyl_64px.png", "100": "static/logo/Tridactyl_100px.png",