X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=version.c;h=6106a8098c8a46575f9afae5da9909b5c196f754;hb=ff3ec8a9a2ed0ee2e62e5990835430bd89a9b4f4;hp=f98d5a654d4a17a9d85157b33f161afe6951a6e8;hpb=9c9b9ede9062ad702a6aa4384a597beb473e0293;p=git.git diff --git a/version.c b/version.c index f98d5a654..6106a8098 100644 --- a/version.c +++ b/version.c @@ -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; +}