Skip to content
Open
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
18 changes: 9 additions & 9 deletions https_everywhere/_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,15 @@ def _is_rule_only_force_https(ruleset, rule):
)
)
return False
else:
# There are five of these, and the pattern and replacement have the same path, so can easily be
# reduced by adding an exclusion as inverse regex of the path in the rule
logger.info(
"{} matches {} but has a path, and is not reducible yet".format(
targets, rule.pattern
)

# There are five of these, and the pattern and replacement have the same path, so can easily be
# reduced by adding an exclusion as inverse regex of the path in the rule
logger.info(
"{} matches {} but has a path, and is not reducible yet".format(
targets, rule.pattern
)
return False
)
return False
else: # pragma: no cover
logger.debug("{} not matches targets {}".format(rule.pattern, targets))
assert rule.pattern_targets[0] in targets
Expand Down Expand Up @@ -444,7 +444,7 @@ def _reduce_ruleset(ruleset):
# ~500 cases
ruleset._rules = REMOVE_WWW_and_FORCE_HTTPS_RULES
return True
elif rule.add_www:
if rule.add_www:
# ~1100 cases
ruleset._rules = ADD_WWW_and_FORCE_HTTPS_RULES
return True
Expand Down
8 changes: 4 additions & 4 deletions https_everywhere/_unregex.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def expand_pattern(pattern, max_count=100):
s, sorted(set(p.host) - valid_host_char)
)
)
else:
return [p.host]

return [p.host]
except urllib3.exceptions.LocationParseError: # pragma: no cover
# TODO: build test case for this
pass
Expand Down Expand Up @@ -130,11 +130,11 @@ def split_regex(pattern, at, remainer=False):
found = True
del pattern[i]
continue
elif not found and tok == sre_parse.IN and (sre_parse.LITERAL, ord(at)) in val:
if not found and tok == sre_parse.IN and (sre_parse.LITERAL, ord(at)) in val:
found = True
del pattern[i]
continue
elif not found and tok == sre_parse.MAX_REPEAT:
if not found and tok == sre_parse.MAX_REPEAT:
val = val[2]
if (sre_parse.LITERAL, ord(at)) in val:
found = True
Expand Down
4 changes: 2 additions & 2 deletions https_everywhere/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def _reverse_host(host, trailing_dot=True):
rv = ".".join(reversed(host.split(".")))
if trailing_dot:
return rv + "."
else:
return rv

return rv


def _check_in(domains, hostname):
Expand Down
4 changes: 2 additions & 2 deletions https_everywhere/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _follow_redirects_on_http(self, url):
if self._prevent_https(tail):
return "http://" + tail
return response
elif location.startswith("http://"):
if location.startswith("http://"):
previous_url = current_url
url = location
else:
Expand Down Expand Up @@ -285,7 +285,7 @@ def send(self, request, *args, **kwargs):
"upgrading {} to https with {}".format(url, redirect.url)
)
return redirect
elif redirect != url:
if redirect != url:
if redirect.startswith("http://"):
tail = url[7:]
else:
Expand Down