Philipp Hörist pushed to branch master at gajim / gajim
Commits: 6730e814 by lovetox at 2020-03-22T22:35:22+01:00 Config: Add missing comment
- - - - - fdd15e44 by lovetox at 2020-03-22T23:03:27+01:00 Refactor get_random_string()
- - - - - 4d599687 by lovetox at 2020-03-22T23:10:03+01:00 Interface: Set resource on account creation
Otherwise the resource is changed on first connect which can trigger the relogin check in the Accounts Dialog
- - - - - 4f5762c7 by lovetox at 2020-03-22T23:20:34+01:00 AccountWizard: Make login button a suggested action
- - - - -
8 changed files:
- gajim/common/cert_store.py - gajim/common/config.py - gajim/common/helpers.py - gajim/common/modules/jingle.py - gajim/common/proxy65_manager.py - gajim/gtk/account_wizard.py - gajim/gtk/filetransfer.py - gajim/gui_interface.py
Changes:
===================================== gajim/common/cert_store.py ===================================== @@ -21,7 +21,7 @@ from gi.repository import Gio
from gajim.common import configpaths
-from gajim.common.helpers import get_random_string_16 +from gajim.common.helpers import get_random_string from gajim.common.helpers import write_file_async
@@ -36,7 +36,7 @@ class CertificateStore: self._load_certificates()
def _get_random_path(self): - filename = get_random_string_16() + filename = get_random_string() path = self._path / filename if path.exists(): return self._get_random_path()
===================================== gajim/common/config.py ===================================== @@ -66,7 +66,7 @@ class Config: DEFAULT_ACTIVITY_ICONSET = 'default'
__options = ({ - # name: [ type, default_value, help_string ] + # name: [ type, default_value, help_string, restart ] 'verbose': [opt_bool, False, '', True], 'autopopup': [opt_bool, False], 'notify_on_signin': [opt_bool, False],
===================================== gajim/common/helpers.py ===================================== @@ -798,15 +798,14 @@ def remove_invalid_xml_chars(string_): string_ = re.sub(app.interface.invalid_XML_chars_re, '', string_) return string_
-def get_random_string_16(): +def get_random_string(count=16): """ - Create random string of length 16 + Create random string of count length + + WARNING: Don't use this for security purposes """ - rng = list(range(65, 90)) - rng.extend(range(48, 57)) - char_sequence = [chr(e) for e in rng] - from random import sample - return ''.join(sample(char_sequence, 16)) + allowed = string.ascii_uppercase + string.digits + return ''.join(random.choice(allowed) for char in range(count))
def get_os_info(): if app.os_info: @@ -1568,11 +1567,9 @@ def get_resource(account): if not resource: return None
- rand = ''.join(random.choice( - string.ascii_uppercase + string.digits) for _ in range(8)) resource = Template(resource).safe_substitute( {'hostname': socket.gethostname(), - 'rand': rand}) + 'rand': get_random_string()}) app.config.set_per('accounts', account, 'resource', resource) return resource
===================================== gajim/common/modules/jingle.py ===================================== @@ -215,7 +215,7 @@ class Jingle(BaseModule): senders=senders) file_props.transport_sid = transport.sid file_props.algo = self.__hash_support(contact) - jingle.add_content('file' + helpers.get_random_string_16(), transfer) + jingle.add_content('file' + helpers.get_random_string(), transfer) jingle.start_session() return transfer.transport.sid
===================================== gajim/common/proxy65_manager.py ===================================== @@ -233,7 +233,7 @@ class ProxyResolver: self.jid = None self.host = None self.port = None - self.sid = helpers.get_random_string_16() + self.sid = helpers.get_random_string() self.sender_jid = sender_jid self.testit = testit
===================================== gajim/gtk/account_wizard.py ===================================== @@ -60,7 +60,7 @@ class AccountWizard(Assistant): css_class='suggested-action') self.add_button('connect', _('Connect'), css_class='suggested-action') self.add_button('next', _('Next'), css_class='suggested-action') - self.add_button('login', _('Log In')) + self.add_button('login', _('Log In'), css_class='suggested-action') self.add_button('back', _('Back'))
self.add_pages({'login': Login(self._on_button_clicked),
===================================== gajim/gtk/filetransfer.py ===================================== @@ -310,7 +310,7 @@ class FileTransfersWindow: account, jid) fjid = contact.get_full_jid() # Request the file to the sender - sid = helpers.get_random_string_16() + sid = helpers.get_random_string() new_file_props = FilesProp.getNewFileProp(account, sid) new_file_props.file_name = file_props.file_name new_file_props.name = file_props.name @@ -721,7 +721,7 @@ class FileTransfersWindow: _('It is not possible to send empty files')) return None file_props = FilesProp.getNewFileProp( - account, sid=helpers.get_random_string_16()) + account, sid=helpers.get_random_string()) mod_date = os.path.getmtime(file_path) file_props.file_name = file_path file_props.name = file_name
===================================== gajim/gui_interface.py ===================================== @@ -1666,6 +1666,7 @@ class Interface: config = {} config['active'] = False config['name'] = username + config['resource'] = 'gajim.%s' % helpers.get_random_string(8) config['account_label'] = '%s@%s' % (username, domain) config['hostname'] = domain config['savepass'] = True
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/cc600fd99114f9f49791196e19345752...