@@ -111,7 +111,7 @@ def do_regulatory_country():
111111 """Regulatory country setting."""
112112 global new_country
113113 # Check if new_country is in list of ISO 3166 alpha-2 country codes.
114- regex = re .compile (bytes ('\n ' + new_country + '\s' , 'ascii' ))
114+ regex = re .compile (bytes ('\\ n' + new_country + '\ \ s' , 'ascii' ))
115115 with open ('/usr/share/zoneinfo/iso3166.tab' ) as iso3166file :
116116 data = mmap .mmap (iso3166file .fileno (), 0 , access = mmap .ACCESS_READ )
117117 # Replace new_country with default_country if invalid.
@@ -171,7 +171,7 @@ def do_ssid():
171171 if not is_regex_in_file (hostapd_conf_file , r'^utf8_ssid=\b' ):
172172 file_replace_line (hostapd_conf_file ,
173173 '^(?P<ssid>ssid2?=(?:[0-9a-fA-F]{2}){1,32}).*$' ,
174- '\g<ssid>\n utf8_ssid=1' )
174+ '\\ g<ssid>\n utf8_ssid=1' )
175175
176176def do_ssid_hidden_state ():
177177 """SSID hidden state setting."""
@@ -192,7 +192,7 @@ def do_ssid_hidden_state():
192192 if not is_regex_in_file (hostapd_conf_file , r'^ignore_broadcast_ssid=\b' ):
193193 file_replace_line (hostapd_conf_file ,
194194 '^(?P<hidden>utf8_ssid=[01]).*$' ,
195- '\g<hidden>\n # Show or hide SSID\n ignore_broadcast_ssid=' + ssid_hidden_state )
195+ '\\ g<hidden>\n # Show or hide SSID\n ignore_broadcast_ssid=' + ssid_hidden_state )
196196 else :
197197 file_replace_line (hostapd_conf_file ,
198198 'ignore_broadcast_ssid=.*' ,
@@ -283,23 +283,23 @@ def do_ip_address():
283283 max_range = str (new_static_ip + default_max_range - 1 )
284284 new_static_ip = str (new_static_ip )
285285
286- ip_regex = "(?:10(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){3}|((172\.(1[6-9]|2[0-9]|3[01]))|192\.168)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){2})"
286+ ip_regex = "(?:10(\\ .(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){3}|((172\\ .(1[6-9]|2[0-9]|3[01]))|192\\ .168)(\ \ .(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){2})"
287287 # Set IP and range in all needed files.
288288 file_replace_line (hosts_file ,
289- '^' + ip_regex + '\s+(?P<host>([a-zA-Z0-9][-a-zA-Z0-9]{0,62}\s*)+)$' ,
290- new_static_ip + '\t \g<host>' )
289+ '^' + ip_regex + '\\ s+(?P<host>([a-zA-Z0-9][-a-zA-Z0-9]{0,62}\ \ s*)+)$' ,
290+ new_static_ip + '\\ t \ \ g<host>' )
291291 file_replace_line (nodogsplash_conf_file ,
292- '^GatewayAddress\s+' + ip_regex ,
292+ '^GatewayAddress\\ s+' + ip_regex ,
293293 'GatewayAddress ' + new_static_ip )
294294 file_replace_line (dnsmasq_conf_file ,
295- '^address=\/home\/.*$' ,
295+ '^address=\\ /home\ \ /.*$' ,
296296 'address=/home/' + new_static_ip )
297297 if is_networkmanager ():
298298 subprocess .run (['sudo' , 'nmcli' , 'con' , 'mod' , 'WifiAP' , 'ipv4.addresses' , new_static_ip + '/24' ])
299299 subprocess .run (['sudo' , 'nmcli' , 'con' , 'mod' , 'WifiAP' , 'ipv4.gateway' , new_static_ip ])
300300 file_replace_line (dnsmasq_conf_file ,
301301 '^dhcp-option=6,' + ip_regex + '(?P<end>.*)$' ,
302- 'dhcp-option=6,' + new_static_ip + '\g<end>' )
302+ 'dhcp-option=6,' + new_static_ip + '\\ g<end>' )
303303 else :
304304 file_replace_line (dhcpcd_conf_file ,
305305 '^static ip_address=.*$' ,
@@ -309,10 +309,10 @@ def do_ip_address():
309309 'listen-address=' + new_static_ip )
310310 file_replace_line (dnsmasq_conf_file ,
311311 '^dhcp-range=wifi,' + ip_regex + ',' + ip_regex + ',(?P<end>.*)$' ,
312- 'dhcp-range=wifi,' + min_range + ',' + max_range + ',\g<end>' )
312+ 'dhcp-range=wifi,' + min_range + ',' + max_range + ',\\ g<end>' )
313313 file_replace_line (dnsmasq_conf_file ,
314314 '^dhcp-option=wifi,6,' + ip_regex + '(?P<end>.*)$' ,
315- 'dhcp-option=wifi,6,' + new_static_ip + '\g<end>' )
315+ 'dhcp-option=wifi,6,' + new_static_ip + '\\ g<end>' )
316316
317317def fix_wrong_kernel_cmdline ():
318318 """Fix buggy file produced by buggy script in version 2.17.0 and 2.17.1."""
0 commit comments