From: Amos Jeffries Date: Thu, 1 Sep 2011 13:52:18 +0000 (+1200) Subject: Bug 3303: Support for non-English usernames in log files X-Git-Tag: take08~33^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd85ea1f12dea2eb2534fffbea8076c86c48628f;p=thirdparty%2Fsquid.git Bug 3303: Support for non-English usernames in log files Also, correct documentation for the default formats. Looks realy weird but according to the code AND the documented option bytes [ is default. --- diff --git a/src/cf.data.pre b/src/cf.data.pre index 273437ff12..307885dbeb 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -3014,9 +3014,9 @@ DOC_START The default formats available (which do not need re-defining) are: -logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %h" "%{User-Agent}>h" %Ss:%Sh +logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %a %[ui %[un [%tl] "%rm %ru HTTP/%rv" %>Hs %a %[ui %[un [%tl] "%rm %ru HTTP/%rv" %>Hs %h" "%{User-Agent}>h" %Ss:%Sh logformat referrer %ts.%03tu %>a %{Referer}>h %ru logformat useragent %>a [%tl] "%{User-Agent}>h" diff --git a/src/format/Format.cc b/src/format/Format.cc index 8da961ef2b..e39861b4c6 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -12,6 +12,8 @@ #include "SquidTime.h" #include "Store.h" +/// Convert a string to NULL pointer if it is "" +#define strOrNull(s) ((s)==NULL||(s)[0]=='\0'?NULL:(s)) Format::Format::Format(const char *n) : format(NULL), @@ -726,44 +728,27 @@ Format::Format::assemble(MemBuf &mb, AccessLogEntry *al, int logSequenceNumber) break; case LFT_USER_NAME: - out = QuoteUrlEncodeUsername(al->cache.authuser); - + out = strOrNull(al->cache.authuser); if (!out) - out = QuoteUrlEncodeUsername(al->cache.extuser); - + out = strOrNull(al->cache.extuser); #if USE_SSL - if (!out) - out = QuoteUrlEncodeUsername(al->cache.ssluser); - + out = strOrNull(al->cache.ssluser); #endif - if (!out) - out = QuoteUrlEncodeUsername(al->cache.rfc931); - - dofree = 1; - + out = strOrNull(al->cache.rfc931); break; case LFT_USER_LOGIN: - out = QuoteUrlEncodeUsername(al->cache.authuser); - - dofree = 1; - + out = strOrNull(al->cache.authuser); break; case LFT_USER_IDENT: - out = QuoteUrlEncodeUsername(al->cache.rfc931); - - dofree = 1; - + out = strOrNull(al->cache.rfc931); break; case LFT_USER_EXTERNAL: - out = QuoteUrlEncodeUsername(al->cache.extuser); - - dofree = 1; - + out = strOrNull(al->cache.extuser); break; /* case LFT_USER_REALM: */