1
Description: Properly load utf8-encoded config files
2
Origin: commit, revision id: pqm@pqm.ubuntu.com-20110620104625-ih5t1e8w288pc4l2
3
Author: Vincent Ladeuil <v.ladeuil+lp@free.fr>
4
Bug: https://launchpad.net/bugs/799212
5
Last-Update: 2011-06-20
6
Applied-Upstream: merged in revision 5988
7
X-Bzr-Revision-Id: pqm@pqm.ubuntu.com-20110620104625-ih5t1e8w288pc4l2
9
=== modified file 'bzrlib/config.py'
10
--- old/bzrlib/config.py 2011-06-19 02:48:01 +0000
11
+++ new/bzrlib/config.py 2011-06-20 09:31:17 +0000
12
@@ -2375,13 +2375,10 @@
14
:param str_or_unicode: A string representing the file content. This will
15
be utf-8 encoded internally.
17
- This is for tests and should not be used in production unless a
18
- convincing use case can be demonstrated :)
21
raise AssertionError('Already loaded: %r' % (self._config_obj,))
22
- co_input = StringIO(str_or_unicode.encode('utf-8'))
23
+ co_input = StringIO(str_or_unicode)
25
# The config files are always stored utf8-encoded
26
self._config_obj = ConfigObj(co_input, encoding='utf-8')
28
=== modified file 'bzrlib/tests/test_config.py'
29
--- old/bzrlib/tests/test_config.py 2011-06-14 10:07:16 +0000
30
+++ new/bzrlib/tests/test_config.py 2011-06-20 09:31:17 +0000
31
@@ -2328,6 +2328,22 @@
32
self.assertRaises(AssertionError, store._load_from_string, 'bar=baz')
35
+class TestBug799212(TestStore):
37
+ def test_load_utf8(self):
38
+ t = self.get_transport()
39
+ # From http://pad.lv/799212
40
+ unicode_user = u'Piotr O\u017carowski'
41
+ unicode_content = u'user=%s' % (unicode_user,)
42
+ utf8_content = unicode_content.encode('utf8')
43
+ # Store the raw content in the config file
44
+ t.put_bytes('foo.conf', utf8_content)
45
+ store = config.IniFileStore(t, 'foo.conf')
47
+ stack = config.Stack([store.get_sections], store)
48
+ self.assertEquals(unicode_user, stack.get('user'))
51
class TestMutableStore(TestStore):
53
scenarios = [(key, {'store_id': key, 'get_store': builder}) for key, builder
55
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
56
--- old/doc/en/release-notes/bzr-2.4.txt 2011-06-18 13:57:17 +0000
57
+++ new/doc/en/release-notes/bzr-2.4.txt 2011-06-20 09:31:17 +0000
62
+* Properly load utf8-encoded config files. (Vincent Ladeuil, #799212)
64
.. Fixes for situations where bzr would previously crash or give incorrect
65
or undesirable results.