From 5b35bde9069bfc0b5cbc34c9430902396794d804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Tue, 7 May 2019 11:58:19 +0100 Subject: config: ensure tabname is not a JID object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tabnames should be treated as opaque strings. This specific fix prevents tabname (JID) to be compared with invalid stringly-typed JIDs. JID's __eq__ method used to (after poezio/slixmpp@47968963) try and convert anything into JIDs. This has been fixed and now properly returns NotImplemented. Signed-off-by: Maxime “pep” Buquet --- poezio/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'poezio/config.py') diff --git a/poezio/config.py b/poezio/config.py index c87f881a..acd5f293 100644 --- a/poezio/config.py +++ b/poezio/config.py @@ -20,6 +20,7 @@ from configparser import RawConfigParser, NoOptionError, NoSectionError from pathlib import Path from shutil import copy2 from typing import Callable, Dict, List, Optional, Union, Tuple +from slixmpp import JID from poezio.args import parse_args from poezio import xdg @@ -214,7 +215,7 @@ class Config(RawConfigParser): def get_by_tabname(self, option, - tabname, + tabname: str, fallback=True, fallback_server=True, default=''): @@ -224,6 +225,8 @@ class Config(RawConfigParser): in the section, we search for the global option if fallback is True. And we return `default` as a fallback as a last resort. """ + if isinstance(tabname, JID): + tabname = tabname.full if self.default and (not default) and fallback: default = self.default.get(DEFSECTION, {}).get(option, '') if tabname in self.sections(): -- cgit v1.2.3