mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 21:51:28 +00:00
Fix DeprecationWarnings about string escapes in regex
This commit is contained in:
@@ -143,7 +143,7 @@ class HostSearch(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def match_port(host_ports, port, port_state):
|
def match_port(host_ports, port, port_state):
|
||||||
# Check if the port is parsable, if not return False silently
|
# Check if the port is parsable, if not return False silently
|
||||||
if re.match("^\d+$", port) is None:
|
if re.match(r"^\d+$", port) is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for hp in host_ports:
|
for hp in host_ports:
|
||||||
@@ -258,10 +258,10 @@ class SearchResult(object):
|
|||||||
fuzz = date_arg.count("~")
|
fuzz = date_arg.count("~")
|
||||||
date_arg = date_arg.replace("~", "")
|
date_arg = date_arg.replace("~", "")
|
||||||
|
|
||||||
if re.match("\d\d\d\d-\d\d-\d\d$", date_arg) is not None:
|
if re.match(r"\d\d\d\d-\d\d-\d\d$", date_arg) is not None:
|
||||||
year, month, day = date_arg.split("-")
|
year, month, day = date_arg.split("-")
|
||||||
parsed_date = date(int(year), int(month), int(day))
|
parsed_date = date(int(year), int(month), int(day))
|
||||||
elif re.match("[-|\+]\d+$", date_arg):
|
elif re.match(r"[-|\+]\d+$", date_arg):
|
||||||
# We need to convert from the "-n" format (n days ago) to a date
|
# We need to convert from the "-n" format (n days ago) to a date
|
||||||
# object (I found this in some old code, don't ask :) )
|
# object (I found this in some old code, don't ask :) )
|
||||||
parsed_date = date.fromordinal(
|
parsed_date = date.fromordinal(
|
||||||
@@ -321,7 +321,7 @@ class SearchResult(object):
|
|||||||
|
|
||||||
# Check if they're parsable, if not return False silently
|
# Check if they're parsable, if not return False silently
|
||||||
for port in ports:
|
for port in ports:
|
||||||
if re.match("^\d+$", port) is None:
|
if re.match(r"^\d+$", port) is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Make a list of all scanned ports
|
# Make a list of all scanned ports
|
||||||
|
|||||||
@@ -780,11 +780,11 @@ class DateSubcriterion(Subcriterion):
|
|||||||
self.fuzzies = argument.count("~")
|
self.fuzzies = argument.count("~")
|
||||||
argument = argument.replace("~", "")
|
argument = argument.replace("~", "")
|
||||||
self.minus_notation = False
|
self.minus_notation = False
|
||||||
if re.match("\d\d\d\d-\d\d-\d\d$", argument) is not None:
|
if re.match(r"\d\d\d\d-\d\d-\d\d$", argument) is not None:
|
||||||
year, month, day = argument.split("-")
|
year, month, day = argument.split("-")
|
||||||
self.date = datetime.date(int(year), int(month), int(day))
|
self.date = datetime.date(int(year), int(month), int(day))
|
||||||
self.argument = argument
|
self.argument = argument
|
||||||
elif re.match("[-|\+]\d+$", argument) is not None:
|
elif re.match(r"[-|\+]\d+$", argument) is not None:
|
||||||
# Convert the date from the "-n" notation into YYYY-MM-DD
|
# Convert the date from the "-n" notation into YYYY-MM-DD
|
||||||
parsed_date = datetime.date.fromordinal(
|
parsed_date = datetime.date.fromordinal(
|
||||||
datetime.date.today().toordinal() + int(argument))
|
datetime.date.today().toordinal() + int(argument))
|
||||||
|
|||||||
Reference in New Issue
Block a user