]> git.pld-linux.org Git - packages/nagios.git/blob - nagios-cgi-http_charset.patch
fix without doc bcond
[packages/nagios.git] / nagios-cgi-http_charset.patch
1 applied in icinga :)
2 https://git.icinga.org/?p=icinga-core.git;a=commit;h=82c07167e482d0936f18f2763a342b78af0b618e
3 https://dev.icinga.org/issues/1002
4
5 but not in nagios :(
6 http://tracker.nagios.org/view.php?id=182
7
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   */
12  int date_format;
13  int interval_length;
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
21 @@ -1033,9 +1033,9 @@
22         printf("Expires: %s\r\n", date_time);
23  
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);
27         else {
28 -               printf("Content-type: text/csv\r\n\r\n");
29 +               printf("Content-type: text/csv; charset=\"%s\"\r\n\r\n", http_charset);
30                 return;
31                 }
32  
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
36 @@ -169,6 +169,9 @@
37         host_unreachable_sound = NULL;
38         normal_sound = NULL;
39  
40 +       my_free(http_charset);
41 +       http_charset = strdup(DEFAULT_HTTP_CHARSET);
42 +
43         statusmap_background_image = NULL;
44         color_transparency_index_r = 255;
45         color_transparency_index_g = 255;
46 @@ -391,6 +394,9 @@
47                 else if(!strcmp(var, "illegal_macro_output_chars"))
48                         illegal_output_chars = strdup(val);
49  
50 +               else if(!strcmp(var, "http_charset"))
51 +                       http_charset = strdup(val);
52 +
53                 else if(!strcmp(var, "notes_url_target"))
54                         notes_url_target = strdup(val);
55  
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
59 @@ -38,6 +38,8 @@
60  
61  extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
62  
63 +extern char *http_charset;
64 +
65  extern int  nagios_process_state;
66  
67  extern int  use_authentication;
68 @@ -242,7 +244,7 @@
69  
70         if(content_type == WML_CONTENT) {
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");
77 @@ -254,7 +256,7 @@
78  
79         else {
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");
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
89 @@ -291,7 +291,7 @@
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);
95  
96         printf("<html>\n");
97         printf("<head>\n");
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
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);
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  
108         if(embedded == TRUE)
109                 return;
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
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);
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  
120                 if(embedded == TRUE)
121                         return;
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
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);
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  
132         if(embedded == TRUE)
133                 return;
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
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);
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  
144         if(embedded == TRUE)
145                 return;
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
149 @@ -34,6 +34,8 @@
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];
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);
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  
165         if(embedded == TRUE)
166                 return;
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
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);
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  
177         if(embedded == TRUE)
178                 return;
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
182 @@ -42,6 +42,8 @@
183  extern char url_media_path[MAX_FILENAME_LENGTH];
184  extern char url_js_path[MAX_FILENAME_LENGTH];
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;
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);
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  
198         if(embedded == TRUE)
199                 return;
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
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);
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  
210                 if(embedded == TRUE)
211                         return;
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
215 @@ -38,6 +38,8 @@
216  
217  extern char     *ping_syntax;
218  
219 +extern char    *http_charset;
220 +
221  #define DISPLAY_HOST                   0
222  #define DISPLAY_SERVICE                 1
223  #define DISPLAY_HOSTGROUP               2
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);
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");
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
236 @@ -39,6 +39,8 @@
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  
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);
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;
253         }
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
257 @@ -662,9 +662,9 @@
258         printf("Expires: %s\r\n", date_time);
259  
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);
263         else {
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;
267                 }
268  
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
272 @@ -50,6 +50,8 @@
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;
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);
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  
288         if(embedded == TRUE)
289                 return;
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
293 @@ -42,6 +42,8 @@
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  
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);
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  
309                 if(embedded == TRUE)
310                         return;
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
314 @@ -408,6 +408,9 @@
315  #define LIFO_ERROR_FILE                2
316  #define LIFO_ERROR_DATA                3
317  
318 +/************************** HTTP CHARSET ****************************/
319 +
320 +#define DEFAULT_HTTP_CHARSET "utf-8"
321  
322  
323  
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
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;
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
338 @@ -35,6 +35,11 @@
339  url_html_path=@htmurl@
340  
341  
342 +# HTTP CHARSET
343 +# This defines charset that is sent with HTTP headers.
344 +
345 +http_charset=utf-8
346 +
347  
348  # CONTEXT-SENSITIVE HELP
349  # This option determines whether or not a context-sensitive
This page took 0.087132 seconds and 3 git commands to generate.