Skip to content

Commit d2db625

Browse files
author
MB
committed
Merge github.com:EFForg/HTTPS-Everywhere
Conflicts: src/chrome/content/rules/Black_Phone.ch.xml src/chrome/content/rules/IFixit.xml src/chrome/content/rules/NK_News.org.xml
2 parents 772e61a + 8e83c80 commit d2db625

File tree

186 files changed

+2288
-916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+2288
-916
lines changed

README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,8 @@ Important directories you might want to know about
5959
Hacking on the Source Code
6060
--------------------------
6161

62-
The current stable release series is 4.0. The current development release series
63-
is 5.0. Each release series is represented by a branch with the major and minor
64-
version numbers, e.g. 4.0 or 5.0. This branch is updated during the lifecycle of
65-
the release series. Specific releases are represented as tags with the full
66-
version number, e.g. 4.0.0 or 5.0development.0.
67-
68-
If you are making a bug fix to the current stable release, you should
69-
work off of the stable branch, 4.0. If you are adding features or improving
70-
functionality, work off of master. The maintainers will merge master into the
71-
development series branch periodically. We will also occasionally merge ruleset
72-
fixes from master into the stable branch if the ruleset is important (i.e. a
73-
popular or high-security site), or if the version in stable is clearly broken.
62+
The current stable release series is 5.0. The maintainers release new versions
63+
off the current master branch about every two weeks.
7464

7565
To submit changes, either use pull requests on GitHub or email patches to
7666
https-everywhere-rulesets@lists.eff.org (rulesets) or

chromium/_locales/de/messages.json

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"menu_blockHttpRequests": {
3-
"message": "Block all HTTP requests"
3+
"message": "Alle HTTP requests blockieren"
44
},
55
"about_title": {
66
"message": "Über HTTPS Everywhere"
@@ -121,6 +121,39 @@
121121
},
122122
"chrome_what_is_this_title": {
123123
"message": "HTTPS-Everywhere-Webseite"
124+
},
125+
"menu_add_rule": {
126+
"message": "Regel für diese Seite hinzufügen"
127+
},
128+
"about_add_new_rule": {
129+
"message": "Eine Regel für diese Seite hinzufügen"
130+
},
131+
"menu_always_https_for_host": {
132+
"message": "Für diese Seite HTTPS erzwingen"
133+
},
134+
"menu_host": {
135+
"message": "Host:"
136+
},
137+
"menu_show_advanced": {
138+
"message": "Erweiterte Optionen anzeigen"
139+
},
140+
"menu_hide_advanced": {
141+
"message": "Erweiterte Optionen verstecken"
142+
},
143+
"menu_rule_name": {
144+
"message": "Regel Name"
145+
},
146+
"menu_regex": {
147+
"message": "Auslösende regex"
148+
},
149+
"menu_redirect_to": {
150+
"message": "Umleiten zu"
151+
},
152+
"menu_add_new_rule": {
153+
"message": "Neue Regel hinzufügen"
154+
},
155+
"status_cancel_button": {
156+
"message": "Abbrechen"
124157
}
125158
}
126159

chromium/_locales/en/messages.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,39 @@
121121
},
122122
"chrome_what_is_this_title": {
123123
"message": "HTTPS Everywhere website"
124+
},
125+
"menu_add_rule": {
126+
"message": "Add a rule for this site"
127+
},
128+
"about_add_new_rule": {
129+
"message": "Add a new rule for this site"
130+
},
131+
"menu_always_https_for_host": {
132+
"message": "Always use https for this host."
133+
},
134+
"menu_host": {
135+
"message": "Host:"
136+
},
137+
"menu_show_advanced": {
138+
"message": "Show advanced"
139+
},
140+
"menu_hide_advanced": {
141+
"message": "Hide advanced"
142+
},
143+
"menu_rule_name": {
144+
"message": "Rule name"
145+
},
146+
"menu_regex": {
147+
"message": "Matching regex"
148+
},
149+
"menu_redirect_to": {
150+
"message": "Redirect to"
151+
},
152+
"menu_add_new_rule": {
153+
"message": "Add new rule"
154+
},
155+
"status_cancel_button": {
156+
"message": "Cancel"
124157
}
125158
}
126159

chromium/background.js

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"use strict";
22
/**
33
* Fetch and parse XML to be loaded as RuleSets.
4+
*
5+
* @param url: a relative URL to local XML
46
*/
57
function getRuleXml(url) {
68
var xhr = new XMLHttpRequest();
@@ -15,7 +17,8 @@ function getRuleXml(url) {
1517
return xhr.responseXML;
1618
}
1719

18-
var all_rules = new RuleSets(navigator.userAgent, LRUCache, localStorage);
20+
// Rules are loaded here
21+
var all_rules = new RuleSets(navigator.userAgent, LRUCache, localStorage);
1922
for (var i = 0; i < rule_list.length; i++) {
2023
all_rules.addFromXml(getRuleXml(rule_list[i]));
2124
}
@@ -48,6 +51,9 @@ chrome.storage.onChanged.addListener(function(changes, areaName) {
4851
}
4952
});
5053

54+
/**
55+
* Load stored user rules
56+
**/
5157
var getStoredUserRules = function() {
5258
var oldUserRuleString = localStorage.getItem(USER_RULE_KEY);
5359
var oldUserRules = [];
@@ -57,6 +63,10 @@ var getStoredUserRules = function() {
5763
return oldUserRules;
5864
};
5965
var wr = chrome.webRequest;
66+
67+
/**
68+
* Load all stored user rules
69+
*/
6070
var loadStoredUserRules = function() {
6171
var rules = getStoredUserRules();
6272
var i;
@@ -68,7 +78,10 @@ var loadStoredUserRules = function() {
6878

6979
loadStoredUserRules();
7080

71-
// Set the icon color correctly
81+
/**
82+
* Set the icon color correctly
83+
* Depending on http-nowhere it should be red/default
84+
*/
7285
var setIconColor = function() {
7386
var newIconPath = httpNowhereOn ? './icon38-red.png' : './icon38.png';
7487
chrome.browserAction.setIcon({
@@ -88,7 +101,11 @@ for (r in rs) {
88101
}
89102
*/
90103

91-
104+
/**
105+
* Adds a new user rule
106+
* @param params: params defining the rule
107+
* @param cb: Callback to call after success/fail
108+
* */
92109
var addNewRule = function(params, cb) {
93110
if (all_rules.addUserRule(params)) {
94111
// If we successfully added the user rule, save it in local
@@ -106,6 +123,9 @@ var addNewRule = function(params, cb) {
106123
}
107124
};
108125

126+
/**
127+
* Adds a listener for removed tabs
128+
* */
109129
function AppliedRulesets() {
110130
this.active_tab_rules = {};
111131

@@ -147,6 +167,11 @@ var domainBlacklist = {};
147167
// TODO: Remove this code if they ever give us a real counter
148168
var redirectCounter = {};
149169

170+
/**
171+
* Called before a HTTP(s) request. Does the heavy lifting
172+
* Cancels the request/redirects it to HTTPS. URL modification happens in here.
173+
* @param details of the handler, see Chrome doc
174+
* */
150175
function onBeforeRequest(details) {
151176
var uri = document.createElement('a');
152177
uri.href = details.url;
@@ -254,8 +279,17 @@ var activeTypes = { stylesheet: 1, script: 1, object: 1, other: 1};
254279
// UI treatment of insecure subframes.
255280
var passiveTypes = { main_frame: 1, sub_frame: 1, image: 1, xmlhttprequest: 1};
256281

257-
// Record a non-HTTPS URL loaded by a given hostname in the Switch Planner, for
258-
// use in determining which resources need to be ported to HTTPS.
282+
/**
283+
* Record a non-HTTPS URL loaded by a given hostname in the Switch Planner, for
284+
* use in determining which resources need to be ported to HTTPS.
285+
* (Reminder: Switch planner is the pro-tool enabled by switching into debug-mode)
286+
*
287+
* @param type: type of the resource (see activeTypes and passiveTypes arrays)
288+
* @param tab_id: The id of the tab
289+
* @param resource_host: The host of the original url
290+
* @param resource_url: the original url
291+
* @param rewritten_url: The url rewritten to
292+
* */
259293
function writeToSwitchPlanner(type, tab_id, resource_host, resource_url, rewritten_url) {
260294
var rw = "rw";
261295
if (rewritten_url == null)
@@ -284,8 +318,11 @@ function writeToSwitchPlanner(type, tab_id, resource_host, resource_url, rewritt
284318
switchPlannerInfo[tab_id][rw][resource_host][active_content][resource_url] = 1;
285319
}
286320

287-
// Return the number of properties in an object. For associative maps, this is
288-
// their size.
321+
/**
322+
* Return the number of properties in an object. For associative maps, this is
323+
* their size.
324+
* @param obj: object to calc the size for
325+
* */
289326
function objSize(obj) {
290327
if (typeof obj == 'undefined') return 0;
291328
var size = 0, key;
@@ -295,8 +332,10 @@ function objSize(obj) {
295332
return size;
296333
}
297334

298-
// Make an array of asset hosts by score so we can sort them,
299-
// presenting the most important ones first.
335+
/**
336+
* Make an array of asset hosts by score so we can sort them,
337+
* presenting the most important ones first.
338+
* */
300339
function sortSwitchPlanner(tab_id, rewritten) {
301340
var asset_host_list = [];
302341
if (typeof switchPlannerInfo[tab_id] === 'undefined' ||
@@ -315,7 +354,9 @@ function sortSwitchPlanner(tab_id, rewritten) {
315354
return asset_host_list;
316355
}
317356

318-
// Format the switch planner output for presentation to a user.
357+
/**
358+
* Format the switch planner output for presentation to a user.
359+
* */
319360
function switchPlannerSmallHtmlSection(tab_id, rewritten) {
320361
var asset_host_list = sortSwitchPlanner(tab_id, rewritten);
321362
if (asset_host_list.length == 0) {
@@ -342,6 +383,9 @@ function switchPlannerSmallHtmlSection(tab_id, rewritten) {
342383
return output;
343384
}
344385

386+
/**
387+
* Create switch planner sections
388+
* */
345389
function switchPlannerRenderSections(tab_id, f) {
346390
return "Unrewritten HTTP resources loaded from this tab (enable HTTPS on " +
347391
"these domains and add them to HTTPS Everywhere):<br/>" +
@@ -351,10 +395,17 @@ function switchPlannerRenderSections(tab_id, f) {
351395
f(tab_id, "rw");
352396
}
353397

398+
/**
399+
* Generate the small switch planner html content
400+
* */
354401
function switchPlannerSmallHtml(tab_id) {
355402
return switchPlannerRenderSections(tab_id, switchPlannerSmallHtmlSection);
356403
}
357404

405+
/**
406+
* Generate a HTML link from urls in map
407+
* map: the map containing the urls
408+
* */
358409
function linksFromKeys(map) {
359410
if (typeof map == 'undefined') return "";
360411
var output = "";
@@ -366,10 +417,16 @@ function linksFromKeys(map) {
366417
return output;
367418
}
368419

420+
/**
421+
* Generate the detailed html fot the switch planner
422+
* */
369423
function switchPlannerDetailsHtml(tab_id) {
370424
return switchPlannerRenderSections(tab_id, switchPlannerDetailsHtmlSection);
371425
}
372426

427+
/**
428+
* Generate the detailed html fot the switch planner, by section
429+
* */
373430
function switchPlannerDetailsHtmlSection(tab_id, rewritten) {
374431
var asset_host_list = sortSwitchPlanner(tab_id, rewritten);
375432
var output = "";
@@ -393,6 +450,10 @@ function switchPlannerDetailsHtmlSection(tab_id, rewritten) {
393450
return output;
394451
}
395452

453+
/**
454+
* monitor cookie changes. Automatically convert them to secure cookies
455+
* @param changeInfo Cookie changed info, see Chrome doc
456+
* */
396457
function onCookieChanged(changeInfo) {
397458
if (!changeInfo.removed && !changeInfo.cookie.secure) {
398459
if (all_rules.shouldSecureCookie(changeInfo.cookie, false)) {
@@ -424,6 +485,10 @@ function onCookieChanged(changeInfo) {
424485
}
425486
}
426487

488+
/**
489+
* handling redirects, breaking loops
490+
* @param details details for the redirect (see chrome doc)
491+
* */
427492
function onBeforeRedirect(details) {
428493
// Catch redirect loops (ignoring about:blank, etc. caused by other extensions)
429494
var prefix = details.redirectUrl.substring(0, 5);
@@ -438,6 +503,7 @@ function onBeforeRedirect(details) {
438503
}
439504
}
440505

506+
// Registers the handler for requests
441507
wr.onBeforeRequest.addListener(onBeforeRequest, {urls: ["https://*/*", "http://*/*"]}, ["blocking"]);
442508

443509
// Try to catch redirect loops on URLs we've redirected to HTTPS.
@@ -447,12 +513,20 @@ wr.onBeforeRedirect.addListener(onBeforeRedirect, {urls: ["https://*/*"]});
447513
// Listen for cookies set/updated and secure them if applicable. This function is async/nonblocking.
448514
chrome.cookies.onChanged.addListener(onCookieChanged);
449515

516+
/**
517+
* disable switch Planner
518+
* @param tabId the Tab to disable for
519+
*/
450520
function disableSwitchPlannerFor(tabId) {
451521
delete switchPlannerEnabledFor[tabId];
452522
// Clear stored URL info.
453523
delete switchPlannerInfo[tabId];
454524
}
455525

526+
/**
527+
* Enable switch planner for specific tab
528+
* @param tabId the tab to enable it for
529+
*/
456530
function enableSwitchPlannerFor(tabId) {
457531
switchPlannerEnabledFor[tabId] = true;
458532
}

chromium/devtools-panel.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ function e(id) {
22
return document.getElementById(id);
33
}
44

5+
/**
6+
* Send message to main extension for HTML to display
7+
* @param type: enable/disable
8+
*/
59
function sendMessage(type) {
610
chrome.runtime.sendMessage({
711
type: type,
812
tabId: chrome.devtools.inspectedWindow.tabId,
913
});
1014
}
1115

12-
// Turn on the Switch Planner recording mode, and hide the long description.
16+
/**
17+
* Turn on the Switch Planner recording mode, and hide the long description.
18+
*/
1319
function enableSwitchPlanner() {
1420
sendMessage("enable");
1521
e("SwitchPlannerDescription").style.display = "none";
@@ -20,15 +26,19 @@ function enableSwitchPlanner() {
2026
chrome.devtools.inspectedWindow.reload();
2127
}
2228

23-
// Disable the switch planner and reload, so any state is forgotten and
24-
// the long description is restored.
29+
/**
30+
* Disable the switch planner and reload, so any state is forgotten and
31+
* the long description is restored.
32+
*/
2533
function disableSwitchPlanner() {
2634
sendMessage("disable");
2735
document.location.reload();
2836
}
2937

30-
// Fetch summary HTML of the planner results from the background page for
31-
// display in the devtools panel.
38+
/**
39+
* Fetch summary HTML of the planner results from the background page for
40+
* display in the devtools panel.
41+
*/
3242
function display() {
3343
chrome.runtime.sendMessage({
3444
type: "getSmallHtml",

0 commit comments

Comments
 (0)