diff options
author | Robin Stocker <robin@nibor.org> | 2014-08-21 23:10:55 +1000 |
---|---|---|
committer | Robin Stocker <robin@nibor.org> | 2014-08-21 23:21:27 +1000 |
commit | ce312d8afbb11e41bb33575f96e073eee7dcc6e8 (patch) | |
tree | 6ccdeb7da050a553866c7bd64f73f7945e5e82e3 /org.eclipse.jgit.test | |
parent | 30953bbb679f776eb170ff846695ec851ca9ed26 (diff) | |
download | jgit-ce312d8afbb11e41bb33575f96e073eee7dcc6e8.tar.gz jgit-ce312d8afbb11e41bb33575f96e073eee7dcc6e8.zip |
Strip "<", ">", and "\n" from name/email in UserConfig
This matches what C Git does, see "stripped" in `man git-commit-tree`.
It also fixes the bug of the user where an user.email like "<>" would
show up as "<<>>" in EGit.
Bug: 439844
Change-Id: I567a3c620e191ce9d37d318417e63cb5d4483419
Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java index d30c1911de..69926f915d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java @@ -214,6 +214,20 @@ public class ConfigTest { } @Test + public void testReadUserConfigWithInvalidCharactersStripped() { + final MockSystemReader mockSystemReader = new MockSystemReader(); + final Config localConfig = new Config(mockSystemReader.openUserConfig( + null, FS.DETECTED)); + + localConfig.setString("user", null, "name", "foo<bar"); + localConfig.setString("user", null, "email", "baz>\nqux@example.com"); + + UserConfig userConfig = localConfig.get(UserConfig.KEY); + assertEquals("foobar", userConfig.getAuthorName()); + assertEquals("bazqux@example.com", userConfig.getAuthorEmail()); + } + + @Test public void testReadBoolean_TrueFalse1() throws ConfigInvalidException { final Config c = parse("[s]\na = true\nb = false\n"); assertEquals("true", c.getString("s", null, "a")); |