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/src/org/eclipse | |
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/src/org/eclipse')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java index 60b4819eda..60ac6f176d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/UserConfig.java @@ -180,7 +180,7 @@ public class UserConfig { username = system().getenv(envKey); } - return username; + return stripInvalidCharacters(username); } /** @@ -204,7 +204,11 @@ public class UserConfig { email = system().getenv(envKey); } - return email; + return stripInvalidCharacters(email); + } + + private static String stripInvalidCharacters(String s) { + return s == null ? null : s.replaceAll("<|>|\n", ""); //$NON-NLS-1$//$NON-NLS-2$ } /** |