diff --git a/.gitmodules b/.gitmodules
index 9bfc39e5b1..f898687600 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -2,6 +2,10 @@
path = addon-sdk
url = https://github.com/mozilla/addon-sdk.git
[submodule "https-everywhere-checker"]
- path = https-everywhere-checker
+ path = test/rules
url = https://github.com/jsha/https-everywhere-checker.git
branch = coverage
+[submodule "translations"]
+ path = translations
+ url = https://git.torproject.org/translation.git
+ branch = https_everywhere
diff --git a/.travis.yml b/.travis.yml
index 0ac47a1fdd..3298cd7642 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,22 +1,38 @@
# Config copied from
# http://www.theautomatedtester.co.uk/blog/2012/using-travis-ci-for-building-and-testing-firefox-addons.html
-# Use node_js because there are maybe more workers?
language: python
python:
- "2.7"
+cache:
+ directories:
+ - $HOME/.cache/pip
+ - $HOME/virtualenv/python2.7_with_system_site_packages
addons:
+ apt:
+ packages:
+ - libxml2-dev
+ - python-dev
+ - libcurl4-openssl-dev
+ - python-lxml
+ - python-software-properties
+ - chromium-browser
firefox: "37.0"
virtualenv:
system_site_packages: true
install:
- - sudo apt-get -qq install libxml2-dev libxslt-dev python-dev libcurl4-openssl-dev python-lxml
- - pip install -r https-everywhere-checker/requirements.txt
-before_script:
- - sh -e /etc/init.d/xvfb start
+ - pip install -r test/rules/requirements.txt
+ - pip install -r test/chromium/requirements.txt
env:
- DISPLAY=':99.0'
+before_script:
+ - export DISPLAY=:99.0
+ - sh -e /etc/init.d/xvfb start
+ - wget https://chromedriver.storage.googleapis.com/2.12/chromedriver_linux64.zip
+ - unzip chromedriver_linux64.zip
+ - mv chromedriver test/chromium/chromedriver
script:
- ./test.sh
+sudo: false
notifications:
email:
recipients:
@@ -27,4 +43,3 @@ notifications:
- "irc.oftc.net#https-everywhere"
on_success: change
on_failure: change
-
diff --git a/Makefile b/Makefile
index 3e55293df3..780ec52a98 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@ prerelease: pkg
pkg:
mkdir pkg
clean:
+ rm -rf pkg/xpi-amo/ pkg/xpi-eff/
rm -f pkg/*.xpi
rm -f src/chrome/content/rules/default.rulesets
rm -f src/defaults/rulesets.sqlite
diff --git a/README.md b/README.md
index 202538ff3a..dc45c93010 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Run the latest code and rulesets in a standalone Firefox profile:
Run the latest code and rulesets in a standalone Chromium profile:
- bash run-chromium.sh
+ bash test-chromium.sh --justrun
Build the Firefox extension as a .xpi package:
@@ -59,18 +59,8 @@ Important directories you might want to know about
Hacking on the Source Code
--------------------------
-The current stable release series is 4.0. The current development release series
-is 5.0. Each release series is represented by a branch with the major and minor
-version numbers, e.g. 4.0 or 5.0. This branch is updated during the lifecycle of
-the release series. Specific releases are represented as tags with the full
-version number, e.g. 4.0.0 or 5.0development.0.
-
-If you are making a bug fix to the current stable release, you should
-work off of the stable branch, 4.0. If you are adding features or improving
-functionality, work off of master. The maintainers will merge master into the
-development series branch periodically. We will also occasionally merge ruleset
-fixes from master into the stable branch if the ruleset is important (i.e. a
-popular or high-security site), or if the version in stable is clearly broken.
+The current stable release series is 5.0. The maintainers release new versions
+off the current master branch about every two weeks.
To submit changes, either use pull requests on GitHub or email patches to
https-everywhere-rulesets@lists.eff.org (rulesets) or
diff --git a/chromium/_locales/de/messages.json b/chromium/_locales/de/messages.json
index 40b7e7aa81..ddb6ffc93f 100644
--- a/chromium/_locales/de/messages.json
+++ b/chromium/_locales/de/messages.json
@@ -1,6 +1,6 @@
{
"menu_blockHttpRequests": {
- "message": "Block all HTTP requests"
+ "message": "Alle HTTP requests blockieren"
},
"about_title": {
"message": "Über HTTPS Everywhere"
@@ -121,6 +121,39 @@
},
"chrome_what_is_this_title": {
"message": "HTTPS-Everywhere-Webseite"
+ },
+ "menu_add_rule": {
+ "message": "Regel für diese Seite hinzufügen"
+ },
+ "about_add_new_rule": {
+ "message": "Eine Regel für diese Seite hinzufügen"
+ },
+ "menu_always_https_for_host": {
+ "message": "Für diese Seite HTTPS erzwingen"
+ },
+ "menu_host": {
+ "message": "Host:"
+ },
+ "menu_show_advanced": {
+ "message": "Erweiterte Optionen anzeigen"
+ },
+ "menu_hide_advanced": {
+ "message": "Erweiterte Optionen verstecken"
+ },
+ "menu_rule_name": {
+ "message": "Regel Name"
+ },
+ "menu_regex": {
+ "message": "Auslösende regex"
+ },
+ "menu_redirect_to": {
+ "message": "Umleiten zu"
+ },
+ "menu_add_new_rule": {
+ "message": "Neue Regel hinzufügen"
+ },
+ "status_cancel_button": {
+ "message": "Abbrechen"
}
}
diff --git a/chromium/_locales/en/messages.json b/chromium/_locales/en/messages.json
index 8d01a04fae..7cf06ab793 100644
--- a/chromium/_locales/en/messages.json
+++ b/chromium/_locales/en/messages.json
@@ -121,6 +121,39 @@
},
"chrome_what_is_this_title": {
"message": "HTTPS Everywhere website"
+ },
+ "menu_add_rule": {
+ "message": "Add a rule for this site"
+ },
+ "about_add_new_rule": {
+ "message": "Add a new rule for this site"
+ },
+ "menu_always_https_for_host": {
+ "message": "Always use https for this host."
+ },
+ "menu_host": {
+ "message": "Host:"
+ },
+ "menu_show_advanced": {
+ "message": "Show advanced"
+ },
+ "menu_hide_advanced": {
+ "message": "Hide advanced"
+ },
+ "menu_rule_name": {
+ "message": "Rule name"
+ },
+ "menu_regex": {
+ "message": "Matching regex"
+ },
+ "menu_redirect_to": {
+ "message": "Redirect to"
+ },
+ "menu_add_new_rule": {
+ "message": "Add new rule"
+ },
+ "status_cancel_button": {
+ "message": "Cancel"
}
}
diff --git a/chromium/background.js b/chromium/background.js
index 235aa2ccfd..632ae9cadb 100644
--- a/chromium/background.js
+++ b/chromium/background.js
@@ -1,8 +1,10 @@
"use strict";
/**
* Fetch and parse XML to be loaded as RuleSets.
+ *
+ * @param url: a relative URL to local XML
*/
-function getRuleXml(url) {
+function loadExtensionFile(url, returnType) {
var xhr = new XMLHttpRequest();
// Use blocking XHR to ensure everything is loaded by the time
// we return.
@@ -12,13 +14,18 @@ function getRuleXml(url) {
if (xhr.readyState != 4) {
return;
}
- return xhr.responseXML;
+ if (returnType === 'xml') {
+ return xhr.responseXML;
+ }
+ return xhr.responseText;
}
-var all_rules = new RuleSets(navigator.userAgent, LRUCache, localStorage);
-for (var i = 0; i < rule_list.length; i++) {
- all_rules.addFromXml(getRuleXml(rule_list[i]));
-}
+
+// Rules are loaded here
+var all_rules = new RuleSets(navigator.userAgent, LRUCache, localStorage);
+var rule_list = 'rules/default.rulesets';
+all_rules.addFromXml(loadExtensionFile(rule_list, 'xml'));
+
var USER_RULE_KEY = 'userRules';
// Records which tabId's are active in the HTTPS Switch Planner (see
@@ -48,6 +55,9 @@ chrome.storage.onChanged.addListener(function(changes, areaName) {
}
});
+/**
+* Load stored user rules
+ **/
var getStoredUserRules = function() {
var oldUserRuleString = localStorage.getItem(USER_RULE_KEY);
var oldUserRules = [];
@@ -57,6 +67,10 @@ var getStoredUserRules = function() {
return oldUserRules;
};
var wr = chrome.webRequest;
+
+/**
+ * Load all stored user rules
+ */
var loadStoredUserRules = function() {
var rules = getStoredUserRules();
var i;
@@ -68,7 +82,10 @@ var loadStoredUserRules = function() {
loadStoredUserRules();
-// Set the icon color correctly
+/**
+ * Set the icon color correctly
+ * Depending on http-nowhere it should be red/default
+ */
var setIconColor = function() {
var newIconPath = httpNowhereOn ? './icon38-red.png' : './icon38.png';
chrome.browserAction.setIcon({
@@ -88,7 +105,11 @@ for (r in rs) {
}
*/
-
+/**
+ * Adds a new user rule
+ * @param params: params defining the rule
+ * @param cb: Callback to call after success/fail
+ * */
var addNewRule = function(params, cb) {
if (all_rules.addUserRule(params)) {
// If we successfully added the user rule, save it in local
@@ -106,6 +127,9 @@ var addNewRule = function(params, cb) {
}
};
+/**
+ * Adds a listener for removed tabs
+ * */
function AppliedRulesets() {
this.active_tab_rules = {};
@@ -147,6 +171,11 @@ var domainBlacklist = {};
// TODO: Remove this code if they ever give us a real counter
var redirectCounter = {};
+/**
+ * Called before a HTTP(s) request. Does the heavy lifting
+ * Cancels the request/redirects it to HTTPS. URL modification happens in here.
+ * @param details of the handler, see Chrome doc
+ * */
function onBeforeRequest(details) {
var uri = document.createElement('a');
uri.href = details.url;
@@ -254,8 +283,17 @@ var activeTypes = { stylesheet: 1, script: 1, object: 1, other: 1};
// UI treatment of insecure subframes.
var passiveTypes = { main_frame: 1, sub_frame: 1, image: 1, xmlhttprequest: 1};
-// Record a non-HTTPS URL loaded by a given hostname in the Switch Planner, for
-// use in determining which resources need to be ported to HTTPS.
+/**
+ * Record a non-HTTPS URL loaded by a given hostname in the Switch Planner, for
+ * use in determining which resources need to be ported to HTTPS.
+ * (Reminder: Switch planner is the pro-tool enabled by switching into debug-mode)
+ *
+ * @param type: type of the resource (see activeTypes and passiveTypes arrays)
+ * @param tab_id: The id of the tab
+ * @param resource_host: The host of the original url
+ * @param resource_url: the original url
+ * @param rewritten_url: The url rewritten to
+ * */
function writeToSwitchPlanner(type, tab_id, resource_host, resource_url, rewritten_url) {
var rw = "rw";
if (rewritten_url == null)
@@ -284,8 +322,11 @@ function writeToSwitchPlanner(type, tab_id, resource_host, resource_url, rewritt
switchPlannerInfo[tab_id][rw][resource_host][active_content][resource_url] = 1;
}
-// Return the number of properties in an object. For associative maps, this is
-// their size.
+/**
+ * Return the number of properties in an object. For associative maps, this is
+ * their size.
+ * @param obj: object to calc the size for
+ * */
function objSize(obj) {
if (typeof obj == 'undefined') return 0;
var size = 0, key;
@@ -295,8 +336,10 @@ function objSize(obj) {
return size;
}
-// Make an array of asset hosts by score so we can sort them,
-// presenting the most important ones first.
+/**
+ * Make an array of asset hosts by score so we can sort them,
+ * presenting the most important ones first.
+ * */
function sortSwitchPlanner(tab_id, rewritten) {
var asset_host_list = [];
if (typeof switchPlannerInfo[tab_id] === 'undefined' ||
@@ -315,7 +358,9 @@ function sortSwitchPlanner(tab_id, rewritten) {
return asset_host_list;
}
-// Format the switch planner output for presentation to a user.
+/**
+* Format the switch planner output for presentation to a user.
+* */
function switchPlannerSmallHtmlSection(tab_id, rewritten) {
var asset_host_list = sortSwitchPlanner(tab_id, rewritten);
if (asset_host_list.length == 0) {
@@ -342,6 +387,9 @@ function switchPlannerSmallHtmlSection(tab_id, rewritten) {
return output;
}
+/**
+ * Create switch planner sections
+ * */
function switchPlannerRenderSections(tab_id, f) {
return "Unrewritten HTTP resources loaded from this tab (enable HTTPS on " +
"these domains and add them to HTTPS Everywhere): " +
@@ -351,10 +399,17 @@ function switchPlannerRenderSections(tab_id, f) {
f(tab_id, "rw");
}
+/**
+ * Generate the small switch planner html content
+ * */
function switchPlannerSmallHtml(tab_id) {
return switchPlannerRenderSections(tab_id, switchPlannerSmallHtmlSection);
}
+/**
+ * Generate a HTML link from urls in map
+ * map: the map containing the urls
+ * */
function linksFromKeys(map) {
if (typeof map == 'undefined') return "";
var output = "";
@@ -366,10 +421,16 @@ function linksFromKeys(map) {
return output;
}
+/**
+ * Generate the detailed html fot the switch planner
+ * */
function switchPlannerDetailsHtml(tab_id) {
return switchPlannerRenderSections(tab_id, switchPlannerDetailsHtmlSection);
}
+/**
+ * Generate the detailed html fot the switch planner, by section
+ * */
function switchPlannerDetailsHtmlSection(tab_id, rewritten) {
var asset_host_list = sortSwitchPlanner(tab_id, rewritten);
var output = "";
@@ -393,6 +454,10 @@ function switchPlannerDetailsHtmlSection(tab_id, rewritten) {
return output;
}
+/**
+ * monitor cookie changes. Automatically convert them to secure cookies
+ * @param changeInfo Cookie changed info, see Chrome doc
+ * */
function onCookieChanged(changeInfo) {
if (!changeInfo.removed && !changeInfo.cookie.secure) {
if (all_rules.shouldSecureCookie(changeInfo.cookie, false)) {
@@ -424,6 +489,10 @@ function onCookieChanged(changeInfo) {
}
}
+/**
+ * handling redirects, breaking loops
+ * @param details details for the redirect (see chrome doc)
+ * */
function onBeforeRedirect(details) {
// Catch redirect loops (ignoring about:blank, etc. caused by other extensions)
var prefix = details.redirectUrl.substring(0, 5);
@@ -438,7 +507,15 @@ function onBeforeRedirect(details) {
}
}
-wr.onBeforeRequest.addListener(onBeforeRequest, {urls: ["https://*/*", "http://*/*"]}, ["blocking"]);
+// Registers the handler for requests
+// We listen to all HTTP hosts, because RequestFilter can't handle tons of url restrictions.
+wr.onBeforeRequest.addListener(onBeforeRequest, {urls: ["http://*/*"]}, ["blocking"]);
+
+// TODO: Listen only to the tiny subset of HTTPS hosts that we rewrite/downgrade.
+var httpsUrlsWeListenTo = ["https://*/*"];
+// See: https://developer.chrome.com/extensions/match_patterns
+wr.onBeforeRequest.addListener(onBeforeRequest, {urls: httpsUrlsWeListenTo}, ["blocking"]);
+
// Try to catch redirect loops on URLs we've redirected to HTTPS.
wr.onBeforeRedirect.addListener(onBeforeRedirect, {urls: ["https://*/*"]});
@@ -447,12 +524,20 @@ wr.onBeforeRedirect.addListener(onBeforeRedirect, {urls: ["https://*/*"]});
// Listen for cookies set/updated and secure them if applicable. This function is async/nonblocking.
chrome.cookies.onChanged.addListener(onCookieChanged);
+/**
+ * disable switch Planner
+ * @param tabId the Tab to disable for
+ */
function disableSwitchPlannerFor(tabId) {
delete switchPlannerEnabledFor[tabId];
// Clear stored URL info.
delete switchPlannerInfo[tabId];
}
+/**
+ * Enable switch planner for specific tab
+ * @param tabId the tab to enable it for
+ */
function enableSwitchPlannerFor(tabId) {
switchPlannerEnabledFor[tabId] = true;
}
diff --git a/chromium/devtools-panel.js b/chromium/devtools-panel.js
index 881d40133a..db216dbeb2 100644
--- a/chromium/devtools-panel.js
+++ b/chromium/devtools-panel.js
@@ -2,6 +2,10 @@ function e(id) {
return document.getElementById(id);
}
+/**
+ * Send message to main extension for HTML to display
+ * @param type: enable/disable
+ */
function sendMessage(type) {
chrome.runtime.sendMessage({
type: type,
@@ -9,7 +13,9 @@ function sendMessage(type) {
});
}
-// Turn on the Switch Planner recording mode, and hide the long description.
+/**
+ * Turn on the Switch Planner recording mode, and hide the long description.
+ */
function enableSwitchPlanner() {
sendMessage("enable");
e("SwitchPlannerDescription").style.display = "none";
@@ -20,15 +26,19 @@ function enableSwitchPlanner() {
chrome.devtools.inspectedWindow.reload();
}
-// Disable the switch planner and reload, so any state is forgotten and
-// the long description is restored.
+/**
+ * Disable the switch planner and reload, so any state is forgotten and
+ * the long description is restored.
+ */
function disableSwitchPlanner() {
sendMessage("disable");
document.location.reload();
}
-// Fetch summary HTML of the planner results from the background page for
-// display in the devtools panel.
+/**
+ * Fetch summary HTML of the planner results from the background page for
+ * display in the devtools panel.
+ */
function display() {
chrome.runtime.sendMessage({
type: "getSmallHtml",
diff --git a/chromium/manifest.json b/chromium/manifest.json
index 218d0b34dc..9abe9fa7fa 100644
--- a/chromium/manifest.json
+++ b/chromium/manifest.json
@@ -5,7 +5,6 @@
"background": {
"scripts": [
"lru.js",
- "rule_list.js",
"rules.js",
"util.js",
"background.js"
@@ -40,5 +39,5 @@
""
],
"update_url": "https://www.eff.org/files/https-everywhere-chrome-updates.xml",
- "version": "2015.4.7"
+ "version": "2015.8.25"
}
\ No newline at end of file
diff --git a/chromium/popup.css b/chromium/popup.css
index c77ab707af..db8a80368d 100644
--- a/chromium/popup.css
+++ b/chromium/popup.css
@@ -25,6 +25,8 @@ section.rules {
/* Favicons */
.rule img {
+ width: 16px;
+ height: 16px;
margin-left: 0.6em;
vertical-align: bottom;
}
diff --git a/chromium/popup.html b/chromium/popup.html
index 2182562d48..22923f589e 100755
--- a/chromium/popup.html
+++ b/chromium/popup.html
@@ -16,28 +16,28 @@
+ >
- Add a rule for this site
+