2 https://git.icinga.org/?p=icinga-core.git;a=commit;h=82c07167e482d0936f18f2763a342b78af0b618e
3 https://dev.icinga.org/issues/1002
6 http://tracker.nagios.org/view.php?id=182
8 --- nagios/common/shared.c~ 2013-09-20 21:01:20.000000000 +0200
9 +++ nagios/common/shared.c 2013-10-01 22:02:51.624429871 +0200
14 +char *http_charset = NULL;
15 char *illegal_output_chars;
16 char illegal_output_char_map[] = CHAR_MAP_INIT(0);
17 time_t program_start = 0L;
18 diff -ur nagios.org/cgi/avail.c nagios/cgi/avail.c
19 --- nagios.org/cgi/avail.c 2013-09-20 21:01:20.000000000 +0200
20 +++ nagios/cgi/avail.c 2013-10-01 21:49:29.426623753 +0200
22 printf("Expires: %s\r\n", date_time);
24 if(output_format == HTML_OUTPUT)
25 - printf("Content-type: text/html\r\n\r\n");
26 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
28 - printf("Content-type: text/csv\r\n\r\n");
29 + printf("Content-type: text/csv; charset=\"%s\"\r\n\r\n", http_charset);
33 diff -ur nagios.org/cgi/cgiutils.c nagios/cgi/cgiutils.c
34 --- nagios.org/cgi/cgiutils.c 2013-09-20 21:01:20.000000000 +0200
35 +++ nagios/cgi/cgiutils.c 2013-10-01 21:49:29.429957215 +0200
37 host_unreachable_sound = NULL;
40 + my_free(http_charset);
41 + http_charset = strdup(DEFAULT_HTTP_CHARSET);
43 statusmap_background_image = NULL;
44 color_transparency_index_r = 255;
45 color_transparency_index_g = 255;
47 else if(!strcmp(var, "illegal_macro_output_chars"))
48 illegal_output_chars = strdup(val);
50 + else if(!strcmp(var, "http_charset"))
51 + http_charset = strdup(val);
53 else if(!strcmp(var, "notes_url_target"))
54 notes_url_target = strdup(val);
56 diff -ur nagios.org/cgi/cmd.c nagios/cgi/cmd.c
57 --- nagios.org/cgi/cmd.c 2013-09-20 21:01:20.000000000 +0200
58 +++ nagios/cgi/cmd.c 2013-10-01 21:49:29.429957215 +0200
61 extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
63 +extern char *http_charset;
65 extern int nagios_process_state;
67 extern int use_authentication;
70 if(content_type == WML_CONTENT) {
72 - printf("Content-type: text/vnd.wap.wml\r\n\r\n");
73 + printf("Content-type: text/vnd.wap.wml; charset=\"%s\"\r\n\r\n", http_charset);
75 printf("<?xml version=\"1.0\"?>\n");
76 printf("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
81 - printf("Content-type: text/html\r\n\r\n");
82 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
86 diff -ur nagios.org/cgi/config.c nagios/cgi/config.c
87 --- nagios.org/cgi/config.c 2013-09-20 21:01:20.000000000 +0200
88 +++ nagios/cgi/config.c 2013-10-01 21:49:29.433290641 +0200
90 printf("Pragma: no-cache\r\n");
91 printf("Last-Modified: %s\r\n", date_time);
92 printf("Expires: %s\r\n", date_time);
93 - printf("Content-type: text/html\r\n\r\n");
94 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
98 diff -ur nagios.org/cgi/extinfo.c nagios/cgi/extinfo.c
99 --- nagios.org/cgi/extinfo.c 2013-09-20 21:01:20.000000000 +0200
100 +++ nagios/cgi/extinfo.c 2013-10-01 21:49:29.433290641 +0200
102 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
103 printf("Expires: %s\r\n", date_time);
105 - printf("Content-type: text/html\r\n\r\n");
106 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
110 diff -ur nagios.org/cgi/histogram.c nagios/cgi/histogram.c
111 --- nagios.org/cgi/histogram.c 2013-09-20 21:01:20.000000000 +0200
112 +++ nagios/cgi/histogram.c 2013-10-01 21:49:29.436624049 +0200
114 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
115 printf("Expires: %s\r\n", date_time);
117 - printf("Content-type: text/html\r\n\r\n");
118 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
122 diff -ur nagios.org/cgi/history.c nagios/cgi/history.c
123 --- nagios.org/cgi/history.c 2013-09-20 21:01:20.000000000 +0200
124 +++ nagios/cgi/history.c 2013-10-01 21:49:29.436624049 +0200
126 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
127 printf("Expires: %s\r\n", date_time);
129 - printf("Content-type: text/html\r\n\r\n");
130 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
134 diff -ur nagios.org/cgi/notifications.c nagios/cgi/notifications.c
135 --- nagios.org/cgi/notifications.c 2013-09-20 21:01:20.000000000 +0200
136 +++ nagios/cgi/notifications.c 2013-10-01 21:49:29.436624049 +0200
138 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
139 printf("Expires: %s\r\n", date_time);
141 - printf("Content-type: text/html\r\n\r\n");
142 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
146 diff -ur nagios.org/cgi/outages.c nagios/cgi/outages.c
147 --- nagios.org/cgi/outages.c 2013-09-20 21:01:20.000000000 +0200
148 +++ nagios/cgi/outages.c 2013-10-01 21:49:29.436624049 +0200
150 extern hoststatus *hoststatus_list;
151 extern servicestatus *servicestatus_list;
153 +extern char *http_charset;
155 extern char main_config_file[MAX_FILENAME_LENGTH];
156 extern char url_html_path[MAX_FILENAME_LENGTH];
157 extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
159 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
160 printf("Expires: %s\r\n", date_time);
162 - printf("Content-type: text/html\r\n\r\n");
163 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
167 diff -ur nagios.org/cgi/showlog.c nagios/cgi/showlog.c
168 --- nagios.org/cgi/showlog.c 2013-09-20 21:01:20.000000000 +0200
169 +++ nagios/cgi/showlog.c 2013-10-01 21:49:29.436624049 +0200
171 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
172 printf("Expires: %s\r\n", date_time);
174 - printf("Content-type: text/html\r\n\r\n");
175 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
179 diff -ur nagios.org/cgi/status.c nagios/cgi/status.c
180 --- nagios.org/cgi/status.c 2013-09-20 21:01:20.000000000 +0200
181 +++ nagios/cgi/status.c 2013-10-01 21:49:29.439957458 +0200
183 extern char url_media_path[MAX_FILENAME_LENGTH];
184 extern char url_js_path[MAX_FILENAME_LENGTH];
186 +extern char *http_charset;
188 extern char *service_critical_sound;
189 extern char *service_warning_sound;
190 extern char *service_unknown_sound;
192 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
193 printf("Expires: %s\r\n", date_time);
195 - printf("Content-type: text/html\r\n\r\n");
196 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
200 diff -ur nagios.org/cgi/statusmap.c nagios/cgi/statusmap.c
201 --- nagios.org/cgi/statusmap.c 2013-09-20 21:01:20.000000000 +0200
202 +++ nagios/cgi/statusmap.c 2013-10-01 21:49:29.439957458 +0200
204 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
205 printf("Expires: %s\r\n", date_time);
207 - printf("Content-Type: text/html\r\n\r\n");
208 + printf("Content-Type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
212 diff -ur nagios.org/cgi/statuswml.c nagios/cgi/statuswml.c
213 --- nagios.org/cgi/statuswml.c 2013-09-20 21:01:20.000000000 +0200
214 +++ nagios/cgi/statuswml.c 2013-10-01 21:49:29.443290866 +0200
217 extern char *ping_syntax;
219 +extern char *http_charset;
221 #define DISPLAY_HOST 0
222 #define DISPLAY_SERVICE 1
223 #define DISPLAY_HOSTGROUP 2
225 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
226 printf("Expires: %s\r\n", date_time);
228 - printf("Content-type: text/vnd.wap.wml\r\n\r\n");
229 + printf("Content-type: text/vnd.wap.wml; charset=\"%s\"\r\n\r\n", http_charset);
231 printf("<?xml version=\"1.0\"?>\n");
232 printf("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
233 diff -ur nagios.org/cgi/statuswrl.c nagios/cgi/statuswrl.c
234 --- nagios.org/cgi/statuswrl.c 2013-09-20 21:01:20.000000000 +0200
235 +++ nagios/cgi/statuswrl.c 2013-10-01 21:49:29.443290866 +0200
237 extern char url_images_path[MAX_FILENAME_LENGTH];
238 extern char url_logo_images_path[MAX_FILENAME_LENGTH];
240 +extern char *http_charset;
242 extern char *statuswrl_include;
244 extern int default_statuswrl_layout_method;
246 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
247 printf("Expires: %s\r\n", date_time);
249 - printf("Content-Type: x-world/x-vrml\r\n\r\n");
250 + printf("Content-Type: x-world/x-vrml; charset=\"%s\"\r\n\r\n", http_charset);
254 diff -ur nagios.org/cgi/summary.c nagios/cgi/summary.c
255 --- nagios.org/cgi/summary.c 2013-09-20 21:01:20.000000000 +0200
256 +++ nagios/cgi/summary.c 2013-10-01 21:49:29.443290866 +0200
258 printf("Expires: %s\r\n", date_time);
260 if(output_format == HTML_OUTPUT)
261 - printf("Content-type: text/html\r\n\r\n");
262 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
264 - printf("Content-type: text/plain\r\n\r\n");
265 + printf("Content-type: text/plain; charset=\"%s\"\r\n\r\n", http_charset);
269 diff -ur nagios.org/cgi/tac.c nagios/cgi/tac.c
270 --- nagios.org/cgi/tac.c 2013-09-20 21:01:20.000000000 +0200
271 +++ nagios/cgi/tac.c 2013-10-01 21:49:29.443290866 +0200
273 extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
274 extern char url_media_path[MAX_FILENAME_LENGTH];
276 +extern char *http_charset;
278 extern int refresh_rate;
280 extern char *service_critical_sound;
282 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
283 printf("Expires: %s\r\n", date_time);
285 - printf("Content-type: text/html\r\n\r\n");
286 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
290 diff -ur nagios.org/cgi/trends.c nagios/cgi/trends.c
291 --- nagios.org/cgi/trends.c 2013-09-20 21:01:20.000000000 +0200
292 +++ nagios/cgi/trends.c 2013-10-01 21:49:29.446624276 +0200
294 extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
295 extern char physical_images_path[MAX_FILENAME_LENGTH];
297 +extern char *http_charset;
299 extern int log_rotation_method;
301 /* archived state types */
302 @@ -1182,7 +1184,7 @@
303 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
304 printf("Expires: %s\r\n", date_time);
306 - printf("Content-type: text/html\r\n\r\n");
307 + printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
311 diff -ur nagios.org/include/cgiutils.h nagios/include/cgiutils.h
312 --- nagios.org/include/cgiutils.h 2013-09-20 21:01:20.000000000 +0200
313 +++ nagios/include/cgiutils.h 2013-10-01 21:49:29.446624276 +0200
315 #define LIFO_ERROR_FILE 2
316 #define LIFO_ERROR_DATA 3
318 +/************************** HTTP CHARSET ****************************/
320 +#define DEFAULT_HTTP_CHARSET "utf-8"
324 diff -ur nagios.org/include/objects.h nagios/include/objects.h
325 --- nagios.org/include/objects.h 2013-09-20 21:01:20.000000000 +0200
326 +++ nagios/include/objects.h 2013-10-01 21:50:02.750744397 +0200
328 struct timeperiod *dependency_period_ptr;
331 +extern char *http_charset;
332 extern struct command *command_list;
333 extern struct timeperiod *timeperiod_list;
334 extern struct host *host_list;
335 diff -ur nagios.org/sample-config/cgi.cfg.in nagios/sample-config/cgi.cfg.in
336 --- nagios.org/sample-config/cgi.cfg.in 2013-09-20 21:01:20.000000000 +0200
337 +++ nagios/sample-config/cgi.cfg.in 2013-10-01 21:49:29.446624276 +0200
339 url_html_path=@htmurl@
343 +# This defines charset that is sent with HTTP headers.
348 # CONTEXT-SENSITIVE HELP
349 # This option determines whether or not a context-sensitive