Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

[Paste2.org] Fix bad regexp. #2222

Merged
merged 1 commit into from Jul 14, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chrome/content/rules/Paste2.org-falsemixed.xml
Expand Up @@ -12,7 +12,7 @@

<!-- (avoiding cf_clearance <= mixed content)
-->
<securecookie host="^\.paste2\.org$" name="^(?:__cfduid|__qca$" />
<securecookie host="^\.paste2\.org$" name="^(?:__cfduid|__qca)$" />


<rule from="^http:"
Expand Down
8 changes: 5 additions & 3 deletions utils/trivial-validate.py
Expand Up @@ -32,7 +32,8 @@ def fail(s):

# Precompile xpath expressions that get run repeatedly.
xpath_exclusion_pattern = etree.XPath("/ruleset/exclusion/@pattern")
xpath_cookie_pattern = etree.XPath("/ruleset/securecookie/@host")
xpath_cookie_host_pattern = etree.XPath("/ruleset/securecookie/@host")
xpath_cookie_name_pattern = etree.XPath("/ruleset/securecookie/@name")

# Load lists of ruleset names whitelisted for downgrade & duplicate rules
thispath = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -44,8 +45,9 @@ def fail(s):

def test_bad_regexp(tree, rulename, from_attrib, to):
# Rules with invalid regular expressions.
"""The 'from' rule contains an invalid extended regular expression."""
patterns = from_attrib + xpath_exclusion_pattern(tree) + xpath_cookie_pattern(tree)
"""The rule contains an invalid extended regular expression."""
patterns = (from_attrib + xpath_exclusion_pattern(tree) +
xpath_cookie_host_pattern(tree) + xpath_cookie_name_pattern(tree))
for pat in patterns:
try:
re.compile(pat)
Expand Down