configuration values are not properly escaped, with hash signs being treated as comments

Bug #86838 reported by Christopher Armstrong
4
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Low
Matt Nordhoff

Bug Description

I have a locations.conf with some custom config options which require quotation of the values, for a bzr plugin I have.

The values generally begin with hash marks (#) as they are IRC channels, so they need to be quoted in order for the config file parser to not ignore them. However, when I push a new branch and locations.conf gets rewritten, it strips out the quote marks I have around those values. Then the next time I try to run bzr I get syntax errors about locations.conf.

Related branches

Revision history for this message
James Henstridge (jamesh) wrote :

A simple test case for this problem:

    >>> from bzrlib.branch import Branch
    >>> b = Branch.open('.')
    >>> config = b.get_config()
    >>> config.set_user_option('foo', 'abc#def')
    >>> config.get_user_option('foo')
    u'abc'

I can reproduce this with bzr-1.0 and bzr.dev r3211. In both cases, the following gets written to the configuration file:

    foo = abc#def

Changed in bzr:
status: New → Confirmed
Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 86838] Re: configuration values are not properly escaped, with hash signs being treated as comments

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Henstridge пишет:
| ** Summary changed:
|
| - locations.conf gets rewritten, dropping necessary quotes
| + configuration values are not properly escaped, with hash signs being treated as comments
|
| ** Changed in: bzr
| Status: New => Confirmed
|

It's actually problem in ConfigObj library. I talked with Michael Foord about
this issue and this bug is fixed in upstream now.

Here is quote from our conversation:

- -------- Исходное сообщение --------
Тема: Re: ConfigObj: inline comments considered harmful
Дата: Tue, 15 Jan 2008 23:13:15 +0000
От: Michael Foord <email address hidden>
Кому: Alexander Belchenko <email address hidden>

Hello Alexander,

This problem is now fixed in SVN.

http://svn.pythonutils.python-hosting.com/trunk/pythonutils/

I'm making some further changes (minor bugfixes and possibly a couple of
new methods 'reload' and 'restore_defaults'). After that a new release
will follow shortly.

Many Thanks

Michael Foord

Alexander Belchenko wrote:
| Michael Foord пишет:
|> <email address hidden> wrote:
|>> Some one has sent you a message via your contact form. They filled
|>> in the
|>> following values :
|>>
|>> comment = We are using ConfigObj in Bazaar project and many bzr
|>> plugins. Recently I discover that your support of inline comments
|>> can create problems with write and then read back string with '#'
|>> sign in it.
|>>
|>> E.g. if I save option from my program, e.g.:
|>>
|>> message = bug #123 fixed
|>>
|>> and then I tru to read back config file, I get only 'bug' as value
|>> of 'message' option.
|>>
|>> It's bad. Any ideas why ConfigObj works in this way?
|>>
|> In order to allow inline comments that aren't part of the value.
|>
|>> Please, don't tell me that we must escape # signs when we write them
|>> to config, and unescape when read back. It's ugly.
|>>
|>
|> You can probably do:
|>
|> message = "bug #123 fixed"
|
| How this possible to do using ConfigObj API?
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHpqD+zYr338mxwCURAsITAJ4ww/TRVzajjwaMPxsV94MGKHu/1gCeKTXe
JNrxivCkJm8OstiwGCmQSCY=
=CIEw
-----END PGP SIGNATURE-----

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 86838] Re: locations.conf gets rewritten, dropping necessary quotes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Henstridge пишет:
| A simple test case for this problem:
|
| >>> from bzrlib.branch import Branch
| >>> b = Branch.open('.')
| >>> config = b.get_config()
| >>> config.set_user_option('foo', 'abc#def')
| >>> config.get_user_option('foo')
| u'abc'
|
| I can reproduce this with bzr-1.0 and bzr.dev r3211. In both cases, the
| following gets written to the configuration file:
|
| foo = abc#def
|

Today new version of ConfigObj 4.5.1 is released with fix for this issue.
We can update ConfigObj instance in bzr.dev.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHq0kHzYr338mxwCURAsZAAJ9aAVio71qjLnILqVOBrCfclcl9DwCfeNgB
b+vvGdIYSsBj4zsswGw50fY=
=JS0+
-----END PGP SIGNATURE-----

Changed in bzr:
assignee: nobody → mnordhoff
importance: Undecided → Low
milestone: none → 1.3
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.