{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1745901932,
"reponame":"libwebsockets",
"desc":"libwebsockets lightweight C networking library",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"c6b0977b220896cf4b97b455672ea7c5",
"commit": {"type":"commit",
"time": 1503836328,
"time_ofs": 480,
"oid_tree": { "oid": "5b68a984ddefc8422581e8de27238817b863fd86", "alias": []},
"oid":{ "oid": "debb7aa04347a6b019b3971409f01c2eaab774b5", "alias": []},
"msg": "LWS_WITH_ACCESS_LOG: add referrer to log format and quotes around user agent",
"sig_commit": { "git_time": { "time": 1503836328, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },
"sig_author": { "git_time": { "time": 1503836328, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }},
"body": "LWS_WITH_ACCESS_LOG: add referrer to log format and quotes around user agent\n\nThis also forces any double-quotes in the UA or referrer to be single-quotes.\n\nThis aligns to log to the \u0022combined log format\u0022 described here\n\nhttps://httpd.apache.org/docs/1.3/logs.html#combined"
,
"diff": "diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c\nindex a6243d0..780d220 100755\n--- a/lib/libwebsockets.c\n+++ b/lib/libwebsockets.c\n@@ -3248,7 +3248,8 @@ lws_set_extension_option(struct lws *wsi, const char *ext_name,\n int\n lws_access_log(struct lws *wsi)\n {\n-\tchar *p \u003d wsi-\u003eaccess_log.user_agent, ass[512];\n+\tchar *p \u003d wsi-\u003eaccess_log.user_agent, ass[512],\n+\t *p1 \u003d wsi-\u003eaccess_log.referrer;\n \tint l;\n \n \tif (!wsi-\u003eaccess_log_pending)\n@@ -3260,9 +3261,12 @@ lws_access_log(struct lws *wsi)\n \tif (!p)\n \t\tp \u003d \u0022\u0022;\n \n-\tl \u003d lws_snprintf(ass, sizeof(ass) - 1, \u0022%s %d %lu %s\u005cn\u0022,\n+\tif (!p1)\n+\t\tp1 \u003d \u0022\u0022;\n+\n+\tl \u003d lws_snprintf(ass, sizeof(ass) - 1, \u0022%s %d %lu \u005c\u0022%s\u005c\u0022 \u005c\u0022%s\u005c\u0022\u005cn\u0022,\n \t\t wsi-\u003eaccess_log.header_log,\n-\t\t wsi-\u003eaccess_log.response, wsi-\u003eaccess_log.sent, p);\n+\t\t wsi-\u003eaccess_log.response, wsi-\u003eaccess_log.sent, p1, p);\n \n \tif (wsi-\u003evhost-\u003elog_fd !\u003d (int)LWS_INVALID_FILE) {\n \t\tif (write(wsi-\u003evhost-\u003elog_fd, ass, l) !\u003d l)\n@@ -3278,6 +3282,10 @@ lws_access_log(struct lws *wsi)\n \t\tlws_free(wsi-\u003eaccess_log.user_agent);\n \t\twsi-\u003eaccess_log.user_agent \u003d NULL;\n \t}\n+\tif (wsi-\u003eaccess_log.referrer) {\n+\t\tlws_free(wsi-\u003eaccess_log.referrer);\n+\t\twsi-\u003eaccess_log.referrer \u003d NULL;\n+\t}\n \twsi-\u003eaccess_log_pending \u003d 0;\n \n \treturn 0;\ndiff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h\nindex 5b5b25d..0aa5410 100644\n--- a/lib/private-libwebsockets.h\n+++ b/lib/private-libwebsockets.h\n@@ -1545,6 +1545,7 @@ struct lws_rewrite;\n struct lws_access_log {\n \tchar *header_log;\n \tchar *user_agent;\n+\tchar *referrer;\n \tunsigned long sent;\n \tint response;\n };\ndiff --git a/lib/server.c b/lib/server.c\nindex 6e7c8b0..7a34111 100644\n--- a/lib/server.c\n+++ b/lib/server.c\n@@ -906,7 +906,7 @@ lws_http_action(struct lws *wsi)\n \t\tconst char *pa, *me;\n \t\tstruct tm *tmp;\n \t\ttime_t t \u003d time(NULL);\n-\t\tint l \u003d 256;\n+\t\tint l \u003d 256, m;\n \n \t\tif (wsi-\u003eaccess_log_pending)\n \t\t\tlws_access_log(wsi);\n@@ -939,6 +939,23 @@ lws_http_action(struct lws *wsi)\n \t\t\t\t\t\t\tl + 1, WSI_TOKEN_HTTP_USER_AGENT);\n \t\t\t\telse\n \t\t\t\t\tlwsl_err(\u0022OOM getting user agent\u005cn\u0022);\n+\n+\t\t\t\tfor (m \u003d 0; m \u003c l; m++)\n+\t\t\t\t\tif (wsi-\u003eaccess_log.user_agent[m] \u003d\u003d '\u005c\u0022')\n+\t\t\t\t\t\twsi-\u003eaccess_log.user_agent[m] \u003d '\u005c'';\n+\t\t\t}\n+\t\t\tl \u003d lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_REFERER);\n+\t\t\tif (l) {\n+\t\t\t\twsi-\u003eaccess_log.referrer \u003d lws_malloc(l + 2);\n+\t\t\t\tif (wsi-\u003eaccess_log.referrer)\n+\t\t\t\t\tlws_hdr_copy(wsi, wsi-\u003eaccess_log.referrer,\n+\t\t\t\t\t\t\tl + 1, WSI_TOKEN_HTTP_REFERER);\n+\t\t\t\telse\n+\t\t\t\t\tlwsl_err(\u0022OOM getting user agent\u005cn\u0022);\n+\n+\t\t\t\tfor (m \u003d 0; m \u003c l; m++)\n+\t\t\t\t\tif (wsi-\u003eaccess_log.referrer[m] \u003d\u003d '\u005c\u0022')\n+\t\t\t\t\t\twsi-\u003eaccess_log.referrer[m] \u003d '\u005c'';\n \t\t\t}\n \t\t\twsi-\u003eaccess_log_pending \u003d 1;\n \t\t}\n","s":{"c":1745901932,"u": 6674}}
],"g": 7574,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}