diff options
Diffstat (limited to 'version.c')
-rw-r--r-- | version.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "version.h" +#include "strbuf.h" const char git_version_string[] = GIT_VERSION; @@ -15,3 +16,23 @@ const char *git_user_agent(void) return agent; } + +const char *git_user_agent_sanitized(void) +{ + static const char *agent = NULL; + + if (!agent) { + struct strbuf buf = STRBUF_INIT; + int i; + + strbuf_addstr(&buf, git_user_agent()); + strbuf_trim(&buf); + for (i = 0; i < buf.len; i++) { + if (buf.buf[i] <= 32 || buf.buf[i] >= 127) + buf.buf[i] = '.'; + } + agent = buf.buf; + } + + return agent; +} |