From ae3f83b3c30d7ab931a20986c9b72ec3f4918def Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Wed, 28 Jun 2023 12:41:54 +0200 Subject: 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: d9f8c9561823daf234e2348b5ea0db2e92d29216 ('views: better dhcp conf parsing when importing clients') --- ogcp/views.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 1c3ede7..316a817 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -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 -- cgit v1.2.3-18-g5258