mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 16:37:52 +01:00
Escape double quotes and backslashes in ssid and psk (#507)
## Description: Escape ssid and psk **Related issue (if applicable):** fixes <link to issue> https://github.com/esphome/issues/issues/81 **Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#<esphome-docs PR number goes here> **Pull request in [esphome-core](https://github.com/esphome/esphome-core) with C++ framework changes (if applicable):** esphome/esphome-core#<esphome-core PR number goes here> ## Checklist: - [X] The code change is tested and works locally. - [n/a] Tests have been added to verify that the new code works (under `tests/` folder). If user exposed functionality or configuration variables are added/changed: - [n/a] Documentation added/updated in [esphomedocs](https://github.com/OttoWinter/esphomedocs). Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
parent
336f12b24d
commit
049807e3ab
@ -61,11 +61,15 @@ api:
|
||||
"""
|
||||
|
||||
|
||||
def sanitize_double_quotes(value):
|
||||
return value.replace('\\', '\\\\').replace('"', '\\"')
|
||||
|
||||
|
||||
def wizard_file(**kwargs):
|
||||
config = BASE_CONFIG.format(**kwargs)
|
||||
|
||||
if kwargs['password']:
|
||||
config += u" password: '{0}'\n\nota:\n password: '{0}'\n".format(kwargs['password'])
|
||||
config += u' password: "{0}"\n\nota:\n password: "{0}"\n'.format(kwargs['password'])
|
||||
else:
|
||||
config += u"\nota:\n"
|
||||
|
||||
@ -75,6 +79,11 @@ def wizard_file(**kwargs):
|
||||
def wizard_write(path, **kwargs):
|
||||
name = kwargs['name']
|
||||
board = kwargs['board']
|
||||
|
||||
kwargs['ssid'] = sanitize_double_quotes(kwargs['ssid'])
|
||||
kwargs['psk'] = sanitize_double_quotes(kwargs['psk'])
|
||||
kwargs['password'] = sanitize_double_quotes(kwargs['password'])
|
||||
|
||||
if 'platform' not in kwargs:
|
||||
kwargs['platform'] = 'ESP8266' if board in ESP8266_BOARD_PINS else 'ESP32'
|
||||
platform = kwargs['platform']
|
||||
|
Loading…
Reference in New Issue
Block a user