Home Information - Your home, your data, organized.
Python
Fixed env-generate.py to better handling escaping chars.
Anthony Cassandra050606ca62e7
diff --git a/deploy/env-generate.py b/deploy/env-generate.pyindex 90c4f978..9ad91d4c 100755--- a/deploy/env-generate.py+++ b/deploy/env-generate.py@@ -286,18 +286,18 @@ class HiEnvironmentGenerator:def _write_file( self ):- line_prefix = ''- if self._destination_filename.endswith( self.SH_FILE_SUFFIX ):- line_prefix = 'export '-+ is_sh_file = self._destination_filename.endswith( self.SH_FILE_SUFFIX )with open( self._destination_filename, 'w' ) as fh:for name, value in self._settings_map.items():value = str(value) # ensure string- escaped_value = value.replace("\"", "\\\"")- if any( c in escaped_value for c in " \t\n\"'" ):- fh.write( f'{line_prefix}{name}="{escaped_value}"\n' )+ if is_sh_file:+ escaped_value = value.replace("\\", "\\\\") # Escape backslashes FIRST+ escaped_value = escaped_value.replace("\"", "\\\"")+ escaped_value = escaped_value.replace("$", "\\$")+ escaped_value = escaped_value.replace("`", "\\`")+ fh.write( f'export {name}="{escaped_value}"\n' )else:- fh.write( f'{line_prefix}{name}={escaped_value}\n' )+ fh.write( f'{name}={value}\n' )continueself.print_success( f'File created: {self._destination_filename}' )diff --git a/src/hi/settings/helpers.py b/src/hi/settings/helpers.pyindex 13d5fc09..eb20e6ec 100644--- a/src/hi/settings/helpers.py+++ b/src/hi/settings/helpers.py@@ -165,7 +165,7 @@ class EnvironmentSettings:extra_host_urls_str = cls.get_env_variable( 'HI_EXTRA_HOST_URLS' )if extra_host_urls_str:host_url_tuple_list = cls.parse_url_list_str( extra_host_urls_str )-+# Assume first extra host is the SITE_DOMAIN, but this does not# matter until Django "sites" feature need to be used (if# ever).@@ -174,7 +174,10 @@ class EnvironmentSettings:env_settings.SITE_DOMAIN = host_url_tuple_list[0][0]for host, url in host_url_tuple_list:-+++ print( f'\nADD = {host}' )+allowed_host_list.append( host )cors_allowed_origins_list.append( url )continue