Skip to content

escaping issues even in default mode #271

@gubenkoved

Description

@gubenkoved

Initially I thought there are escaping issue only when we use list_values=False, but it seems like escaping does not work properly even in default mode. Below hand-crafter value sample that is not encoded correctly even in default mode.

Sample program reproducing the issue:

import configobj


if __name__ == "__main__":
    config = configobj.ConfigObj(
        "config.ini",
        encoding='utf-8',
        # list_values=False,
    )

    print('loaded', config)

    if 'foo' not in config:
        config['foo'] = {}

    config['foo']['bar'] = '\'"""hello""" # world'

    print('before write:', config)

    config.write()
    config.reload()

    print('after reload:', config)

Produces output:

loaded {}
before write: {'foo': {'bar': '\'"""hello""" # world'}}
after reload: {'foo': {'bar': '\'"""hello'}}

Config written:

[foo]
bar = """'"""hello""" # world"""

Related: #270.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions