Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

[HTTPS Everywhere] simplify ruleset pattern for HTTPSE 6.0 #13133

Merged
merged 1 commit into from
Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions app/httpsEverywhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,26 @@ function getRewrittenUrl (url) {
function applyRuleset (url, applicableRule) {
var i, ruleset, exclusion, rule, fromPattern, newUrl, exclusionPattern
ruleset = applicableRule.ruleset
// If the rule is default_off or has a specified platform, ignore it.
if (ruleset.$.default_off || ruleset.$.platform) {
return null
}
exclusion = ruleset.exclusion
rule = ruleset.rule
// If covered by an exclusion, callback the original URL without trying any
// more rulesets.
if (exclusion) {
for (i = 0; i < exclusion.length; ++i) {
exclusionPattern = new RegExp(exclusion[i].$.pattern)
exclusionPattern = new RegExp(exclusion[i].pattern)
if (exclusionPattern.test(url)) {
return null
}
}
}
// Find the first rule that triggers a substitution
for (i = 0; i < rule.length; ++i) {
fromPattern = new RegExp(rule[i].$.from)
newUrl = url.replace(fromPattern, rule[i].$.to)
fromPattern = new RegExp(rule[i].from)
newUrl = url.replace(fromPattern, rule[i].to)
if (newUrl !== url) {
return {
redirectURL: newUrl,
ruleset: ruleset.$.f
ruleset: ruleset.name
}
}
}
Expand Down Expand Up @@ -210,5 +206,6 @@ function canonicalizeUrl (url) {
* Loads HTTPS Everywhere
*/
module.exports.init = () => {
dataFile.init(module.exports.resourceName, undefined, startHttpsEverywhere, loadRulesets)
// Force redownload on startup for update from <0.21.x to 0.21.x or higher.
dataFile.init(module.exports.resourceName, undefined, startHttpsEverywhere, loadRulesets, true)
}
2 changes: 1 addition & 1 deletion js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
},
httpsEverywhere: {
url: 'https://s3.amazonaws.com/https-everywhere-data/{version}/httpse.json',
version: '5.2', // latest major point release from https://eff.org/https-everywhere
version: '6.0',
msBetweenRechecks: 1000 * 60 * 60 * 12, // 1/2 day
enabled: true
},
Expand Down