summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2023-06-28 12:41:54 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-06-28 12:48:22 +0200
commitae3f83b3c30d7ab931a20986c9b72ec3f4918def (patch)
tree4db0be369330cee6524dd175e3d1bb6918db9a7c /ogcp
parentd9f8c9561823daf234e2348b5ea0db2e92d29216 (diff)
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')
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/views.py12
1 files 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