views: use \s to match whitespace in client import regex

Some programs substitute regular space characters (\u0020) by en spaces
(\u2002) when displaying monospace text. Others replace it by
non-breaking spaces.

Using a character set such as [ \t\n] to match any possible "space
related" character. Use \s to match any kind of whitespace related
character in the regex.

Pasted from python's documentation:

\s

    For Unicode (str) patterns:

	Matches Unicode whitespace characters (which includes
	[ \t\n\r\f\v], and also many other characters, for example the
	non-breaking spaces mandated by typography rules in many languages). If
	the ASCII flag is used, only [ \t\n\r\f\v] is matched.
	[...]

Fixes: d9f8c95618
('views: better dhcp conf parsing when importing clients')
master
Jose M. Guisado 2023-06-28 12:41:54 +02:00
parent d9f8c95618
commit ae3f83b3c3
1 changed files with 6 additions and 6 deletions

View File

@ -937,15 +937,15 @@ def action_clients_import_get():
scopes=scopes)
OG_REGEX_DHCPD_CONF = (r'(?: *host *)'
OG_REGEX_DHCPD_CONF = (r'(?:\s*host\s*)'
r'([\w.-]*)'
r'(?:[ \n\r]*{[ \n\r]*)'
r'(?:[ \t]*hardware *ethernet *)'
r'(?:\s*{[ \n\r]*)'
r'(?:\s*hardware *ethernet *)'
r'((?:[0-9A-Fa-f]{2}[:-]){5}(?:[0-9A-Fa-f]{2}))'
r'(?: *;)'
r'(?:[ \t\n\r]*fixed-address *)'
r'(?:\s*;)'
r'(?:\s*fixed-address *)'
r'(\d+\.\d+\.\d+\.\d+)'
r'(?: *;)(?:[ \r\n]*[^}]*})')
r'(?:\s*;)(?:\s*[^}]*})')
OG_CLIENT_DEFAULT_BOOT = "pxe"
OG_CLIENT_DEFAULT_LIVEDIR = "ogLive"
OG_CLIENT_DEFAULT_MAINTENANCE = False