From a7c04b3720318834bdbba1e9149e7d373516b0f6 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 9 Jun 2025 00:49:02 +0200 Subject: git: Allow usernames and emails with newlines in them Not going to happen but why not use NUL delimiter when it's available. --- server/common/src/git.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/common/src/git.rs') diff --git a/server/common/src/git.rs b/server/common/src/git.rs index 6678db7..c6a44e3 100644 --- a/server/common/src/git.rs +++ b/server/common/src/git.rs @@ -69,7 +69,7 @@ fn io_err(action: &str, e: std::io::Error) -> Error { } fn parse_user(output: String) -> User { - let mut lines = output.lines(); + let mut lines = output.split_terminator('\0'); let name = lines.next().unwrap_or("").to_string(); let username = lines.next().unwrap_or("").to_string(); let email = lines.next().unwrap_or("").to_string(); @@ -325,13 +325,13 @@ impl RepoData { } async fn get_author(&self, repo: &Repository, commit: &str) -> Result { - self.get_log_format(repo, commit, "%an%n%al%n%ae") + self.get_log_format(repo, commit, "%an%x00%al%x00%ae") .map_ok(parse_user) .await } async fn get_commiter(&self, repo: &Repository, commit: &str) -> Result { - self.get_log_format(repo, commit, "%cn%n%cl%n%ce") + self.get_log_format(repo, commit, "%cn%x00%cl%x00%ce") .map_ok(parse_user) .await } -- cgit v1.2.3-70-g09d2