[tbb-commits] [torbutton/master] Bug 21999: Detect homepage URLs more effectively
gk at torproject.org
gk at torproject.org
Tue Jul 11 12:58:59 UTC 2017
commit 8af90b3222529f9b863229a32dd62b2f9f941d19
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date: Sun Jul 9 23:17:28 2017 -0700
Bug 21999: Detect homepage URLs more effectively
---
src/chrome/content/torbutton.js | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index b14585b..0c297aa 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -2275,6 +2275,25 @@ function torbutton_get_current_accept_language_value(aURI)
return null;
}
+// Take URL strings the user has specified for a homepage
+// and normalize it so it looks like a real URL.
+function torbutton_normalize_homepage_url_string(aURLString)
+{
+ if (!aURLString) return null;
+ if (typeof aURLString !== "string") return null;
+ let url;
+ try {
+ url = new URL(aURLString);
+ } catch (e) {
+ try {
+ url = new URL("http://" + aURLString);
+ } catch (e) {
+ return null;
+ }
+ }
+ return url.href;
+}
+
function torbutton_is_homepage_url(aURI)
{
if (!aURI)
@@ -2292,7 +2311,8 @@ function torbutton_is_homepage_url(aURI)
if (!homePageURLs)
return false;
- let urls = homePageURLs.split('|');
+ let urls = homePageURLs.split('|')
+ .map(torbutton_normalize_homepage_url_string);
return (urls.indexOf(aURI.spec) >= 0);
}
More information about the tbb-commits
mailing list