|
25 | 25 | import java.util.HashSet;
|
26 | 26 | import java.util.List;
|
27 | 27 |
|
| 28 | +import com.google.common.html.HtmlEscapers; |
28 | 29 | import net.opentsdb.core.Const;
|
29 | 30 | import net.opentsdb.core.TSDB;
|
30 | 31 | import net.opentsdb.graph.Plot;
|
@@ -373,14 +374,18 @@ public void internalError(final Exception cause) {
|
373 | 374 | buf.append("\"}");
|
374 | 375 | sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR, buf);
|
375 | 376 | } else {
|
| 377 | + String response = ""; |
| 378 | + if (pretty_exc != null) { |
| 379 | + response = HtmlEscapers.htmlEscaper().escape(pretty_exc); |
| 380 | + } |
376 | 381 | sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR,
|
377 | 382 | makePage("Internal Server Error", "Houston, we have a problem",
|
378 | 383 | "<blockquote>"
|
379 | 384 | + "<h1>Internal Server Error</h1>"
|
380 | 385 | + "Oops, sorry but your request failed due to a"
|
381 | 386 | + " server error.<br/><br/>"
|
382 | 387 | + "Please try again in 30 seconds.<pre>"
|
383 |
| - + pretty_exc |
| 388 | + + response |
384 | 389 | + "</pre></blockquote>"));
|
385 | 390 | }
|
386 | 391 | }
|
@@ -420,14 +425,18 @@ public void badRequest(final BadRequestException exception) {
|
420 | 425 | buf.append("\"}");
|
421 | 426 | sendReply(HttpResponseStatus.BAD_REQUEST, buf);
|
422 | 427 | } else {
|
| 428 | + String response = ""; |
| 429 | + if (exception.getMessage() != null) { |
| 430 | + response = HtmlEscapers.htmlEscaper().escape(exception.getMessage()); |
| 431 | + } |
423 | 432 | sendReply(HttpResponseStatus.BAD_REQUEST,
|
424 | 433 | makePage("Bad Request", "Looks like it's your fault this time",
|
425 | 434 | "<blockquote>"
|
426 | 435 | + "<h1>Bad Request</h1>"
|
427 | 436 | + "Sorry but your request was rejected as being"
|
428 | 437 | + " invalid.<br/><br/>"
|
429 | 438 | + "The reason provided was:<blockquote>"
|
430 |
| - + exception.getMessage() |
| 439 | + + response |
431 | 440 | + "</blockquote></blockquote>"));
|
432 | 441 | }
|
433 | 442 | }
|
|
0 commit comments