--- nagios-3.0.3/cgi/avail.c 2008-06-23 23:47:42.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/avail.c 2008-10-11 12:34:44.496658785 +0300 @@ -37,6 +37,8 @@ extern char url_images_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern host *host_list; extern hostgroup *hostgroup_list; extern servicegroup *servicegroup_list; @@ -1079,9 +1081,9 @@ printf("Expires: %s\r\n", date_time); if(output_format == HTML_OUTPUT) - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); else { - printf("Content-type: text/plain\r\n\r\n"); + printf("Content-type: text/plain; charset=\"%s\"\r\n\r\n", http_charset); return; } --- nagios-3.2.0/cgi/cgiutils.c 2009-09-11 16:14:43.130251761 +0300 +++ nagios-3.2.0/cgi/cgiutils.c 2009-09-15 14:46:13.332409409 +0300 @@ -55,6 +55,7 @@ char *statuswrl_include = NULL; char *illegal_output_chars = NULL; +char *http_charset = NULL; char *notes_url_target = NULL; char *action_url_target = NULL; @@ -188,6 +189,9 @@ host_unreachable_sound = NULL; normal_sound = NULL; + my_free(http_charset); + http_charset = strdup(DEFAULT_HTTP_CHARSET); + statusmap_background_image = NULL; color_transparency_index_r = 255;; @@ -391,6 +395,9 @@ else if(!strcmp(var, "illegal_macro_output_chars")) illegal_output_chars = strdup(val); + else if(!strcmp(var, "http_charset")) + http_charset = strdup(val); + else if(!strcmp(var, "notes_url_target")) notes_url_target = strdup(val); @@ -1478,6 +1485,9 @@ } } + /* high bit chars don't get encoded, so we won't be breaking utf8 characters */ + else if ((unsigned char)input[x] >= 0x7f) + encoded_html_string[y++]=input[x]; /* for simplicity, all other chars represented by their numeric value */ else{ if(escape_html_tags == FALSE) --- nagios-3.0.3/cgi/cmd.c 2008-05-19 21:42:26.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/cmd.c 2008-10-11 12:34:44.496658785 +0300 @@ -39,6 +39,8 @@ extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern int nagios_process_state; extern int check_external_commands; @@ -235,7 +237,7 @@ if(content_type==WML_CONTENT){ - printf("Content-type: text/vnd.wap.wml\r\n\r\n"); + printf("Content-type: text/vnd.wap.wml; charset=\"%s\"\r\n\r\n", http_charset); printf("\n"); printf("\n"); @@ -247,7 +249,7 @@ else{ - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); printf("\n"); printf("\n"); --- nagios-3.0.3/cgi/config.c 2008-04-13 21:34:27.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/config.c 2008-10-11 12:34:44.496658785 +0300 @@ -37,6 +37,8 @@ extern char url_logo_images_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern host *host_list; extern service *service_list; extern hostgroup *hostgroup_list; @@ -293,7 +295,7 @@ printf("Pragma: no-cache\r\n"); printf("Last-Modified: %s\r\n", date_time); printf("Expires: %s\r\n", date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); printf("\n"); printf("\n"); --- nagios-3.0.3/cgi/extinfo.c 2008-01-24 04:51:30.000000000 +0200 +++ nagios-3.0.3-cgi/cgi/extinfo.c 2008-10-11 12:34:44.500659016 +0300 @@ -38,6 +38,8 @@ extern int nagios_process_state; extern int refresh_rate; +extern char *http_charset; + extern time_t program_start; extern int nagios_pid; extern int daemon_mode; @@ -584,7 +586,7 @@ get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/cgi/histogram.c 2008-05-19 21:42:26.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/histogram.c 2008-10-11 12:34:44.512659708 +0300 @@ -130,6 +130,8 @@ extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; extern char physical_images_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern int log_rotation_method; extern host *host_list; @@ -994,7 +996,7 @@ get_time_string(&expire_time,date_time,sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3-cgi/cgi/history.c 2008-10-11 12:34:44.480657862 +0300 +++ nagios-3.0.3/cgi/history.c 2008-10-11 12:38:12.164637148 +0300 @@ -57,6 +57,8 @@ extern char url_images_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern int log_rotation_method; extern int enable_splunk_integration; @@ -315,7 +317,7 @@ get_time_string(&expire_time,date_time,sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/cgi/notifications.c 2008-05-19 21:42:27.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/notifications.c 2008-10-11 12:34:44.500659016 +0300 @@ -37,6 +37,8 @@ extern char url_docs_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern int log_rotation_method; @@ -303,7 +305,7 @@ get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/cgi/outages.c 2008-01-09 19:51:23.000000000 +0200 +++ nagios-3.0.3-cgi/cgi/outages.c 2008-10-11 12:34:44.500659016 +0300 @@ -39,6 +39,8 @@ extern hoststatus *hoststatus_list; extern servicestatus *servicestatus_list; +extern char *http_charset; + extern char main_config_file[MAX_FILENAME_LENGTH]; extern char url_html_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; @@ -215,7 +217,7 @@ get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/cgi/showlog.c 2008-01-09 19:51:23.000000000 +0200 +++ nagios-3.0.3-cgi/cgi/showlog.c 2008-10-11 12:34:44.500659016 +0300 @@ -37,6 +37,8 @@ extern char url_images_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern int log_rotation_method; extern int enable_splunk_integration; @@ -188,7 +190,7 @@ get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/cgi/status.c 2008-06-23 23:47:46.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/status.c 2008-10-11 12:34:44.504659246 +0300 @@ -44,6 +44,8 @@ extern char url_media_path[MAX_FILENAME_LENGTH]; extern char log_file[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern char *service_critical_sound; extern char *service_warning_sound; extern char *service_unknown_sound; @@ -503,7 +505,7 @@ get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/cgi/statusmap.c 2008-05-19 21:42:28.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/statusmap.c 2008-10-11 12:34:44.508659477 +0300 @@ -54,6 +54,8 @@ extern char url_logo_images_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern host *host_list; extern hostgroup *hostgroup_list; extern service *service_list; @@ -320,7 +322,7 @@ get_time_string(&expire_time,date_time,sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-Type: text/html\r\n\r\n"); + printf("Content-Type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/cgi/statuswml.c 2008-05-19 21:42:28.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/statuswml.c 2008-10-11 12:34:44.504659246 +0300 @@ -47,6 +47,8 @@ extern char *ping_syntax; +extern char *http_charset; + #define DISPLAY_HOST 0 #define DISPLAY_SERVICE 1 #define DISPLAY_HOSTGROUP 2 @@ -193,7 +195,7 @@ get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/vnd.wap.wml\r\n\r\n"); + printf("Content-type: text/vnd.wap.wml; charset=\"%s\"\r\n\r\n", http_charset); printf("\n"); printf("\n"); --- nagios-3.0.3/cgi/statuswrl.c 2007-07-16 19:41:46.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/statuswrl.c 2008-10-11 12:34:44.508659477 +0300 @@ -41,6 +41,8 @@ extern char url_images_path[MAX_FILENAME_LENGTH]; extern char url_logo_images_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern char *statuswrl_include; extern host *host_list; @@ -202,7 +204,7 @@ get_time_string(&expire_time,date_time,sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-Type: x-world/x-vrml\r\n\r\n"); + printf("Content-Type: x-world/x-vrml; charset=\"%s\"\r\n\r\n", http_charset); return; } --- nagios-3.0.3/cgi/summary.c 2008-01-24 04:51:30.000000000 +0200 +++ nagios-3.0.3-cgi/cgi/summary.c 2008-10-11 12:34:44.504659246 +0300 @@ -37,6 +37,8 @@ extern char url_images_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern host *host_list; extern hostgroup *hostgroup_list; extern service *service_list; @@ -698,9 +700,9 @@ printf("Expires: %s\r\n", date_time); if(output_format == HTML_OUTPUT) - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); else { - printf("Content-type: text/plain\r\n\r\n"); + printf("Content-type: text/plain; charset=\"%s\"\r\n\r\n", http_charset); return; } --- nagios-3.0.3/cgi/tac.c 2008-02-21 08:17:37.000000000 +0200 +++ nagios-3.0.3-cgi/cgi/tac.c 2008-10-11 12:34:44.508659477 +0300 @@ -52,6 +52,8 @@ extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; extern char url_media_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern int refresh_rate; extern char *service_critical_sound; @@ -381,7 +383,7 @@ get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/cgi/trends.c 2008-06-23 23:47:46.000000000 +0300 +++ nagios-3.0.3-cgi/cgi/trends.c 2008-10-11 12:34:44.512659708 +0300 @@ -44,6 +44,8 @@ extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; extern char physical_images_path[MAX_FILENAME_LENGTH]; +extern char *http_charset; + extern int log_rotation_method; extern host *host_list; @@ -1114,7 +1116,7 @@ get_time_string(&expire_time,date_time,sizeof(date_time),HTTP_DATE_TIME); printf("Expires: %s\r\n",date_time); - printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset); if(embedded==TRUE) return; --- nagios-3.0.3/include/cgiutils.h 2007-11-11 01:34:26.000000000 +0200 +++ nagios-3.0.3-cgi/include/cgiutils.h 2008-10-11 12:34:44.468657170 +0300 @@ -422,6 +422,9 @@ #define LIFO_ERROR_FILE 2 #define LIFO_ERROR_DATA 3 +/************************** HTTP CHARSET ****************************/ + +#define DEFAULT_HTTP_CHARSET "utf-8" --- nagios-3.0.3/sample-config/cgi.cfg.in 2007-10-07 22:42:52.000000000 +0300 +++ nagios-3.0.3-cgi/sample-config/cgi.cfg.in 2008-10-11 12:34:44.472657400 +0300 @@ -36,6 +36,11 @@ url_html_path=@htmurl@ +# HTTP CHARSET +# This defines charset that is sent with HTTP headers. + +http_charset=utf-8 + # CONTEXT-SENSITIVE HELP # This option determines whether or not a context-sensitive