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

Commit

Permalink
Merge pull request #13133 from brave/feature/httpse-6.0
Browse files Browse the repository at this point in the history
[HTTPS Everywhere] simplify ruleset pattern for HTTPSE 6.0
  • Loading branch information
bsclifton committed Feb 16, 2018
1 parent 79e672f commit 4aebee3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
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

0 comments on commit 4aebee3

Please sign in to comment.