--- zabbix-2.2.6/src/zabbix_server/httppoller/httpmacro.c Wed Aug 27 22:07:23 2014 +++ zabbix-2.2.6/src/zabbix_server/httppoller/httpmacro.c Mon Oct 27 15:44:06 2014 @@ -26,6 +26,8 @@ #define REGEXP_PREFIX "regex:" #define REGEXP_PREFIX_SIZE (sizeof(REGEXP_PREFIX) - 1) +#define ESCAPE_PREFIX "escape:" +#define ESCAPE_PREFIX_SIZE (sizeof(ESCAPE_PREFIX) - 1) /****************************************************************************** * * @@ -85,6 +87,7 @@ size_t key_size = 0, key_offset = 0, value_size = 0, value_offset = 0; zbx_ptr_pair_t pair = {NULL, NULL}; int index, ret = FAIL; + int escape_value = 0; zabbix_log(LOG_LEVEL_DEBUG, "In %s() pkey:'%.*s' pvalue:'%.*s'", __function_name, (int)nkey, pkey, (int)nvalue, pvalue); @@ -129,6 +132,11 @@ /* get macro value */ zbx_strncpy_alloc(&value_str, &value_size, &value_offset, pvalue, nvalue); + if (0 == strncmp(ESCAPE_PREFIX, value_str, ESCAPE_PREFIX_SIZE)) + { + escape_value = 1; + memmove(value_str, value_str + ESCAPE_PREFIX_SIZE, strlen(value_str) - ESCAPE_PREFIX_SIZE + 1); + } if (0 == strncmp(REGEXP_PREFIX, value_str, REGEXP_PREFIX_SIZE)) { /* The value contains regexp pattern, retrieve the first captured group or fail. */ @@ -165,6 +173,20 @@ else pair.second = value_str; + if (NULL != pair.second && escape_value) + { + CURL *easyhandle = NULL; + char *escaped; + + if (NULL != (easyhandle = curl_easy_init())) + { + escaped = curl_easy_escape(easyhandle, pair.second, strlen(pair.second)); + pair.second = zbx_strdup(pair.second, escaped); + curl_free(escaped); + curl_easy_cleanup(easyhandle); + } + } + /* get macro name */ zbx_strncpy_alloc((char**)&pair.first, &key_size, &key_offset, pkey, nkey);