view .eslintrc.js @ 8299:6f9970a36190

auth_ldap: fix interpretation of LDAP attributes in Python 3 The python-ldap module returns the LDAP attribute names as strings, and the attribute values as arrays of bytes, e.g. for email: 'mail': [b'john.doe@example.com'], See https://www.python-ldap.org/en/latest/bytes_mode.html, particularly: https://www.python-ldap.org/en/latest/bytes_mode.html#what-s-text-and-what-s-bytes Due to a missing conversion from bytes to unicode for the attribute values obtained from LDAP, storing the values in a unicode field in the database would fail. It would apparently either store a repr of the bytes or store them in some other way. Upon user login, SQLAlchemy warned about this: .../sqlalchemy/sql/sqltypes.py:269: SAWarning: Unicode type received non-unicode bind param value b'John'. (this warning may be suppressed after 10 occurrences) .../sqlalchemy/sql/sqltypes.py:269: SAWarning: Unicode type received non-unicode bind param value b'Doe'. (this warning may be suppressed after 10 occurrences) In PostgreSQL, this would result in 'weird' values for first name, last name, and email fields, both in the database and the web UI, e.g. firstname: \x4a6f686e lastname: \x446f65 email: \x6a6f686e406578616d706c652e636f6d These values represent the actual values in hexadecimal, e.g. \x4a6f686e = 0x4a 0x6f 0x68 0x6e = J o h n In SQLite, the problem initially shows differently, as an exception in gravatar_url(): File "_base_root_html", line 207, in render_body File "_index_html", line 78, in render_header_menu File "_base_base_html", line 479, in render_menu File ".../kallithea/lib/helpers.py", line 908, in gravatar_div gravatar(email_address, cls=cls, size=size))) File ".../kallithea/lib/helpers.py", line 923, in gravatar src = gravatar_url(email_address, size * 2) File ".../kallithea/lib/helpers.py", line 956, in gravatar_url .replace('{email}', email_address) \ TypeError: replace() argument 2 must be str, not bytes but nevertheless the root cause of the problem is the same. Fix the problem by converting the LDAP attributes from bytes to strings.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Sun, 22 Mar 2020 21:22:23 +0100
parents 4d36432bf705
children
line wrap: on
line source

module.exports = {
    "env": {
        "browser": true,
        "es6": true,
        "jquery": true
    },
    "extends": "eslint:recommended",
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parserOptions": {
        "ecmaVersion": 2018,
        "sourceType": "module"
    },
    "plugins": [
        "html"
    ],
    "rules": {
    }
};