Skip to content

Commit

Permalink
Fix invalid/deprecated escape sequences
Browse files Browse the repository at this point in the history
There are a couple more invalid escape sequences. These are not meant to
be Python string escape sequences, but literal backspace used for those
regular expressions. Use the raw string prefix r"" for these strings.
  • Loading branch information
agners committed Aug 13, 2024
1 parent 3a0b0b9 commit b8b07d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions cpe/comp/cpecomp2_3_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class CPEComponent2_3_FS(CPEComponent2_3):
###############

# Patterns used to check the value of component
_UNRESERVED = "\w|\.|\-"
_PUNC = "\!|\"|\;|\#|\$|\%|\&|\'|\(|\)|\+|\,|\/|\:|\<|\=|\>|\@|\[|\]|\^|\`|\{|\||\}|\~|\-"
_UNRESERVED = r"\w|\.|\-"
_PUNC = r"\!|\"|\;|\#|\$|\%|\&|\'|\(|\)|\+|\,|\/|\:|\<|\=|\>|\@|\[|\]|\^|\`|\{|\||\}|\~|\-"

#: Separator of components of CPE name with URI style
SEPARATOR_COMP = ":"
Expand All @@ -74,9 +74,9 @@ class CPEComponent2_3_FS(CPEComponent2_3):
###############

# Compilation of regular expression associated with value of CPE part
_logical = "(\{0}|{1})".format(VALUE_ANY, VALUE_NA)
_quest = "\{0}".format(WILDCARD_ONE)
_asterisk = "\{0}".format(WILDCARD_MULTI)
_logical = r"(\{0}|{1})".format(VALUE_ANY, VALUE_NA)
_quest = r"\{0}".format(WILDCARD_ONE)
_asterisk = r"\{0}".format(WILDCARD_MULTI)
_special = "{0}|{1}".format(_quest, _asterisk)
_spec_chrs = "{0}+|{1}".format(_quest, _asterisk)
_quoted = r"\\(\\" + "|{0}|{1})".format(_special, _PUNC)
Expand Down
10 changes: 5 additions & 5 deletions cpe/comp/cpecomp2_3_wfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CPEComponent2_3_WFN(CPEComponent2_3):

# Patterns used to check the value of component
_ESCAPE = r"\\"
_PUNC_NO_DASH = "\!|\"|\;|\#|\$|\%|\&|\'|\(|\)|\+|\,|\.|\/|\:|\<|\=|\>|\@|\[|\]|\^|\`|\{|\||\}|\~"
_PUNC_NO_DASH = r"\!|\"|\;|\#|\$|\%|\&|\'|\(|\)|\+|\,|\.|\/|\:|\<|\=|\>|\@|\[|\]|\^|\`|\{|\||\}|\~"

#: Separator of components of CPE name with URI style
SEPARATOR_COMP = ", "
Expand Down Expand Up @@ -74,17 +74,17 @@ class CPEComponent2_3_WFN(CPEComponent2_3):
# VARIABLES #
###############

_spec1 = "\{0}".format(WILDCARD_ONE)
_spec2 = "\{0}".format(WILDCARD_MULTI)
_spec1 = r"\{0}".format(WILDCARD_ONE)
_spec2 = r"\{0}".format(WILDCARD_MULTI)
_spec_chrs = "{0}+|{1}".format(_spec1, _spec2)
_special = "{0}|{1}".format(_spec1, _spec2)
_punc_w_dash = "{0}|-".format(_PUNC_NO_DASH)
_quoted1 = "{0}({1}|{2}|{3})".format(_ESCAPE, _ESCAPE, _special,
_PUNC_NO_DASH)
_quoted2 = "{0}({1}|{2}|{3})".format(_ESCAPE, _ESCAPE,
_special, _punc_w_dash)
_body1 = "\w|{0}".format(_quoted1)
_body2 = "\w|{0}".format(_quoted2)
_body1 = r"\w|{0}".format(_quoted1)
_body2 = r"\w|{0}".format(_quoted2)
_body = "(({0})({1})*)|{2}({3})+".format(_body1, _body2, _body2, _body2)
_avstring_pattern = "^((({0})|(({1})({2})*))({3})?)$".format(_body,
_spec_chrs,
Expand Down
2 changes: 1 addition & 1 deletion cpe/comp/cpecomp_anyvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CPEComponentAnyValue(CPEComponentLogical):
For example, in version 2.3 of CPE specification, an component "any value"
is other attribute in CPE name
cpe:2.3:a:microsft:windows:xp:\*:\*:\*:\*:\*:\*:\*.
cpe:2.3:a:microsft:windows:xp:*:*:*:*:*:*:*.
"""

####################
Expand Down

0 comments on commit b8b07d3

Please sign in to comment.