Merge "Strip "<", ">", and "\n" from name/email in UserConfig"
This commit is contained in:
commit
82f74e490a
|
@ -213,6 +213,20 @@ public void test007_readUserConfig() {
|
||||||
assertFalse(localConfig.get(UserConfig.KEY).isCommitterEmailImplicit());
|
assertFalse(localConfig.get(UserConfig.KEY).isCommitterEmailImplicit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void testReadBoolean_TrueFalse1() throws ConfigInvalidException {
|
public void testReadBoolean_TrueFalse1() throws ConfigInvalidException {
|
||||||
final Config c = parse("[s]\na = true\nb = false\n");
|
final Config c = parse("[s]\na = true\nb = false\n");
|
||||||
|
|
|
@ -180,7 +180,7 @@ private static String getNameInternal(Config rc, String envKey) {
|
||||||
username = system().getenv(envKey);
|
username = system().getenv(envKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return username;
|
return stripInvalidCharacters(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,7 +204,11 @@ private static String getEmailInternal(Config rc, String envKey) {
|
||||||
email = system().getenv(envKey);
|
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$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue