]> git.pld-linux.org Git - packages/nagios.git/blame - nagios-cgi-http_charset.patch
fix without doc bcond
[packages/nagios.git] / nagios-cgi-http_charset.patch
CommitLineData
a18fb3be
ER
1applied in icinga :)
2https://git.icinga.org/?p=icinga-core.git;a=commit;h=82c07167e482d0936f18f2763a342b78af0b618e
3https://dev.icinga.org/issues/1002
4
5but not in nagios :(
6http://tracker.nagios.org/view.php?id=182
7
e277f689
AM
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
10@@ -9,6 +9,7 @@
11 */
fa363e1f
AM
12 int date_format;
13 int interval_length;
e277f689 14+char *http_charset = NULL;
fa363e1f 15 char *illegal_output_chars;
e277f689
AM
16 char illegal_output_char_map[] = CHAR_MAP_INIT(0);
17 time_t program_start = 0L;
18diff -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
21@@ -1033,9 +1033,9 @@
f9ffdd32 22 printf("Expires: %s\r\n", date_time);
f6f70ac5 23
f9ffdd32 24 if(output_format == HTML_OUTPUT)
f6f70ac5
ER
25- printf("Content-type: text/html\r\n\r\n");
26+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
f9ffdd32 27 else {
4ad96cc5
ER
28- printf("Content-type: text/csv\r\n\r\n");
29+ printf("Content-type: text/csv; charset=\"%s\"\r\n\r\n", http_charset);
f6f70ac5 30 return;
4ad96cc5 31 }
f6f70ac5 32
e277f689
AM
33diff -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
36@@ -169,6 +169,9 @@
f9ffdd32 37 host_unreachable_sound = NULL;
38 normal_sound = NULL;
f6f70ac5
ER
39
40+ my_free(http_charset);
41+ http_charset = strdup(DEFAULT_HTTP_CHARSET);
42+
f9ffdd32 43 statusmap_background_image = NULL;
e277f689
AM
44 color_transparency_index_r = 255;
45 color_transparency_index_g = 255;
46@@ -391,6 +394,9 @@
f9ffdd32 47 else if(!strcmp(var, "illegal_macro_output_chars"))
48 illegal_output_chars = strdup(val);
f6f70ac5 49
f9ffdd32 50+ else if(!strcmp(var, "http_charset"))
51+ http_charset = strdup(val);
f6f70ac5 52+
f9ffdd32 53 else if(!strcmp(var, "notes_url_target"))
54 notes_url_target = strdup(val);
f6f70ac5 55
e277f689
AM
56diff -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
59@@ -38,6 +38,8 @@
f6f70ac5
ER
60
61 extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
62
63+extern char *http_charset;
64+
65 extern int nagios_process_state;
66
e277f689
AM
67 extern int use_authentication;
68@@ -242,7 +244,7 @@
f6f70ac5 69
e277f689 70 if(content_type == WML_CONTENT) {
f6f70ac5
ER
71
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);
74
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");
e277f689 77@@ -254,7 +256,7 @@
f6f70ac5 78
e277f689 79 else {
f6f70ac5
ER
80
81- printf("Content-type: text/html\r\n\r\n");
82+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
83
84 printf("<html>\n");
85 printf("<head>\n");
e277f689
AM
86diff -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
89@@ -291,7 +291,7 @@
f6f70ac5 90 printf("Pragma: no-cache\r\n");
f9ffdd32 91 printf("Last-Modified: %s\r\n", date_time);
92 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
93- printf("Content-type: text/html\r\n\r\n");
94+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
95
96 printf("<html>\n");
97 printf("<head>\n");
e277f689
AM
98diff -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
101@@ -537,7 +537,7 @@
102 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
103 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
104
105- printf("Content-type: text/html\r\n\r\n");
106+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
107
e277f689 108 if(embedded == TRUE)
f6f70ac5 109 return;
e277f689
AM
110diff -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
113@@ -983,7 +983,7 @@
114 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
115 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
116
117- printf("Content-type: text/html\r\n\r\n");
118+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
119
e277f689 120 if(embedded == TRUE)
f6f70ac5 121 return;
e277f689
AM
122diff -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
125@@ -285,7 +285,7 @@
126 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
127 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
128
129- printf("Content-type: text/html\r\n\r\n");
130+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
131
e277f689 132 if(embedded == TRUE)
f6f70ac5 133 return;
e277f689
AM
134diff -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
137@@ -272,7 +272,7 @@
138 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
139 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
140
141- printf("Content-type: text/html\r\n\r\n");
142+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
143
e277f689 144 if(embedded == TRUE)
f6f70ac5 145 return;
e277f689
AM
146diff -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
149@@ -34,6 +34,8 @@
f6f70ac5
ER
150 extern hoststatus *hoststatus_list;
151 extern servicestatus *servicestatus_list;
152
153+extern char *http_charset;
154+
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];
e277f689
AM
158@@ -171,7 +173,7 @@
159 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
160 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
161
162- printf("Content-type: text/html\r\n\r\n");
163+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
164
e277f689 165 if(embedded == TRUE)
f6f70ac5 166 return;
e277f689
AM
167diff -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
170@@ -157,7 +157,7 @@
171 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
172 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
173
174- printf("Content-type: text/html\r\n\r\n");
175+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
176
e277f689 177 if(embedded == TRUE)
f6f70ac5 178 return;
e277f689
AM
179diff -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
182@@ -42,6 +42,8 @@
f6f70ac5 183 extern char url_media_path[MAX_FILENAME_LENGTH];
e277f689 184 extern char url_js_path[MAX_FILENAME_LENGTH];
f6f70ac5
ER
185
186+extern char *http_charset;
187+
188 extern char *service_critical_sound;
189 extern char *service_warning_sound;
190 extern char *service_unknown_sound;
e277f689
AM
191@@ -505,7 +507,7 @@
192 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
193 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
194
195- printf("Content-type: text/html\r\n\r\n");
196+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
197
e277f689 198 if(embedded == TRUE)
f6f70ac5 199 return;
e277f689
AM
200diff -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
203@@ -321,7 +321,7 @@
204 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
205 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
206
207- printf("Content-Type: text/html\r\n\r\n");
208+ printf("Content-Type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
209
e277f689 210 if(embedded == TRUE)
f6f70ac5 211 return;
e277f689
AM
212diff -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
215@@ -38,6 +38,8 @@
f6f70ac5 216
66b4f57f
AM
217 extern char *ping_syntax;
218
219+extern char *http_charset;
f6f70ac5 220+
66b4f57f
AM
221 #define DISPLAY_HOST 0
222 #define DISPLAY_SERVICE 1
223 #define DISPLAY_HOSTGROUP 2
e277f689
AM
224@@ -194,7 +196,7 @@
225 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
226 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
227
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);
230
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");
e277f689
AM
233diff -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
236@@ -39,6 +39,8 @@
f6f70ac5
ER
237 extern char url_images_path[MAX_FILENAME_LENGTH];
238 extern char url_logo_images_path[MAX_FILENAME_LENGTH];
239
240+extern char *http_charset;
241+
242 extern char *statuswrl_include;
243
e277f689
AM
244 extern int default_statuswrl_layout_method;
245@@ -197,7 +199,7 @@
246 get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
247 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
248
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);
251
252 return;
e277f689
AM
253 }
254diff -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
257@@ -662,9 +662,9 @@
f9ffdd32 258 printf("Expires: %s\r\n", date_time);
f6f70ac5 259
f9ffdd32 260 if(output_format == HTML_OUTPUT)
f6f70ac5
ER
261- printf("Content-type: text/html\r\n\r\n");
262+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
f9ffdd32 263 else {
f6f70ac5
ER
264- printf("Content-type: text/plain\r\n\r\n");
265+ printf("Content-type: text/plain; charset=\"%s\"\r\n\r\n", http_charset);
266 return;
e277f689 267 }
f6f70ac5 268
e277f689
AM
269diff -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
272@@ -50,6 +50,8 @@
f6f70ac5
ER
273 extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
274 extern char url_media_path[MAX_FILENAME_LENGTH];
275
276+extern char *http_charset;
277+
278 extern int refresh_rate;
279
280 extern char *service_critical_sound;
e277f689
AM
281@@ -281,7 +283,7 @@
282 get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
283 printf("Expires: %s\r\n", date_time);
f6f70ac5
ER
284
285- printf("Content-type: text/html\r\n\r\n");
286+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
287
e277f689 288 if(embedded == TRUE)
f6f70ac5 289 return;
e277f689
AM
290diff -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
293@@ -42,6 +42,8 @@
f6f70ac5
ER
294 extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
295 extern char physical_images_path[MAX_FILENAME_LENGTH];
296
297+extern char *http_charset;
298+
299 extern int log_rotation_method;
300
e277f689
AM
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);
f6f70ac5
ER
305
306- printf("Content-type: text/html\r\n\r\n");
307+ printf("Content-type: text/html; charset=\"%s\"\r\n\r\n", http_charset);
308
e277f689 309 if(embedded == TRUE)
f6f70ac5 310 return;
e277f689
AM
311diff -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
314@@ -408,6 +408,9 @@
f6f70ac5
ER
315 #define LIFO_ERROR_FILE 2
316 #define LIFO_ERROR_DATA 3
317
318+/************************** HTTP CHARSET ****************************/
319+
90efa8f5 320+#define DEFAULT_HTTP_CHARSET "utf-8"
f6f70ac5
ER
321
322
323
e277f689
AM
324diff -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
327@@ -707,6 +707,7 @@
328 struct timeperiod *dependency_period_ptr;
329 } hostdependency;
330
331+extern char *http_charset;
332 extern struct command *command_list;
333 extern struct timeperiod *timeperiod_list;
334 extern struct host *host_list;
335diff -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
338@@ -35,6 +35,11 @@
f6f70ac5
ER
339 url_html_path=@htmurl@
340
341
342+# HTTP CHARSET
343+# This defines charset that is sent with HTTP headers.
344+
90efa8f5 345+http_charset=utf-8
f6f70ac5
ER
346+
347
348 # CONTEXT-SENSITIVE HELP
349 # This option determines whether or not a context-sensitive
This page took 0.07668 seconds and 4 git commands to generate.