From fa8c53e0971a6f3d7b207ecd2d4f5a54d8c9baf7 Mon Sep 17 00:00:00 2001 From: Madhur Garg Date: Sat, 16 Mar 2019 06:30:43 +0530 Subject: Hides the value of 'password' field being displayed in the InfoTab. Fixes #3426 --- poezio/config.py | 2 ++ poezio/core/commands.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/poezio/config.py b/poezio/config.py index d5a81c0e..19069ddb 100644 --- a/poezio/config.py +++ b/poezio/config.py @@ -447,6 +447,8 @@ class Config(RawConfigParser): RawConfigParser.set(self, section, option, value) if not self.write_in_file(section, option, value): return ('Unable to write in the config file', 'Error') + if 'password' in option and 'eval_password' not in option: + value = '*'*len(value) return ("%s=%s" % (option, value), 'Info') def remove_and_save(self, option: str, diff --git a/poezio/core/commands.py b/poezio/core/commands.py index fd6279ec..e48aaff9 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -526,6 +526,8 @@ class CommandCore: theme.COLOR_INFORMATION_TEXT), }) for option_name, option_value in section.items(): + if 'password' in option_name and 'eval_password' not in option_name: + option_value = '*'*len(option_value) lines.append( '%s\x19%s}=\x19o%s' % (option_name, dump_tuple( @@ -534,6 +536,8 @@ class CommandCore: elif len(args) == 1: option = args[0] value = config.get(option) + if 'password' in option and 'eval_password' not in option and value is not None: + value = '*'*len(value) if value is None and '=' in option: args = option.split('=', 1) info = ('%s=%s' % (option, value), 'Info') @@ -591,7 +595,7 @@ class CommandCore: section = args[0] option = args[1] value = args[2] - info = config.set_and_save(option, value, section) + info = config.set_and_save(option, value_info, section) self.core.trigger_configuration_change(option, value) elif len(args) > 3: return self.help('set') -- cgit v1.2.3 From 0ed0bd3c6b332d10d35d440618016aec0980f7bc Mon Sep 17 00:00:00 2001 From: Madhur Garg Date: Sat, 16 Mar 2019 06:42:43 +0530 Subject: Fixes variable name #3426 --- poezio/core/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poezio/core/commands.py b/poezio/core/commands.py index e48aaff9..f1466cb7 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -595,7 +595,7 @@ class CommandCore: section = args[0] option = args[1] value = args[2] - info = config.set_and_save(option, value_info, section) + info = config.set_and_save(option, value, section) self.core.trigger_configuration_change(option, value) elif len(args) > 3: return self.help('set') -- cgit v1.2.3 From 614ea5423b4ca0c14de525e6b4cc03568d1a3eae Mon Sep 17 00:00:00 2001 From: Madhur Garg Date: Sun, 17 Mar 2019 15:21:16 +0530 Subject: Fixes coding style; Corrected indentation and use of static length when displaying hidden value #3426 --- poezio/config.py | 2 +- poezio/core/commands.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/poezio/config.py b/poezio/config.py index 19069ddb..89b75d94 100644 --- a/poezio/config.py +++ b/poezio/config.py @@ -448,7 +448,7 @@ class Config(RawConfigParser): if not self.write_in_file(section, option, value): return ('Unable to write in the config file', 'Error') if 'password' in option and 'eval_password' not in option: - value = '*'*len(value) + value = '********' return ("%s=%s" % (option, value), 'Info') def remove_and_save(self, option: str, diff --git a/poezio/core/commands.py b/poezio/core/commands.py index f1466cb7..c9605987 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -527,7 +527,7 @@ class CommandCore: }) for option_name, option_value in section.items(): if 'password' in option_name and 'eval_password' not in option_name: - option_value = '*'*len(option_value) + option_value = '********' lines.append( '%s\x19%s}=\x19o%s' % (option_name, dump_tuple( @@ -537,7 +537,7 @@ class CommandCore: option = args[0] value = config.get(option) if 'password' in option and 'eval_password' not in option and value is not None: - value = '*'*len(value) + value = '********' if value is None and '=' in option: args = option.split('=', 1) info = ('%s=%s' % (option, value), 'Info') -- cgit v1.2.3