OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
3.0 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../nginx/mod_rrd_graph-0.2.0-0001-space-quoting.diff
  5. # Copyright (C) 2012 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From a67111a39ed3505e29bfe4133e449d61e9a50679 Mon Sep 17 00:00:00 2001
  17. From: Evan Miller <emmiller+github@gmail.com>
  18. Date: Wed, 16 May 2012 17:36:20 -0500
  19. Subject: [PATCH] Support spaces with quotation marks around strings
  20. ---
  21. README | 2 ++
  22. ngx_http_rrd_graph_module.c | 18 ++++++++++++++----
  23. 2 files changed, 16 insertions(+), 4 deletions(-)
  24. diff --git a/README b/README
  25. index a123ee7..b334248 100644
  26. --- a/README
  27. +++ b/README
  28. @@ -32,6 +32,8 @@ becomes:
  29. http://mysite.com/rrdtool--start%20now-300s%20--end%20now%20DEF%3Ads0%3Dtest.rrd%3Areading%3AAVERAGE%20LINE1%3Ads0%2300FF00
  30. +If you need spaces in arguments, put quotation marks ("") around the string.
  31. +
  32. The module supports all the features of your copy of RRDtool. It can output
  33. PNG, PDF, SVG, and EPS graphics (see the --imgformat option of rrdgraph(1)).
  34. diff --git a/ngx_http_rrd_graph_module.c b/ngx_http_rrd_graph_module.c
  35. index ad305e3..f43cd7e 100644
  36. --- a/ngx_http_rrd_graph_module.c
  37. +++ b/ngx_http_rrd_graph_module.c
  38. @@ -151,7 +151,7 @@ static ngx_int_t
  39. ngx_http_rrd_graph_parse_uri(ngx_http_request_t *r, int *argc_ptr,
  40. char ***argv_ptr, size_t **argv_len_ptr)
  41. {
  42. - int i, argc = 3;
  43. + int i, argc = 3, in_quote = 0;
  44. char **argv;
  45. size_t *argv_len;
  46. char *tmp, *p;
  47. @@ -174,9 +174,16 @@ ngx_http_rrd_graph_parse_uri(ngx_http_request_t *r, int *argc_ptr,
  48. uri_copy[r->uri.len] = '\0'; /* RRDtool needs null-terminated strings */
  49. p = (char *)uri_copy + clcf->name.len;
  50. - while(*p++)
  51. - if (*p == ' ')
  52. + while(*p++) {
  53. + if (*p == '"') {
  54. + in_quote = !in_quote;
  55. + } else if (*p == ' ' && !in_quote) {
  56. argc++;
  57. + }
  58. + }
  59. +
  60. + if (in_quote)
  61. + return NGX_ERROR;
  62. argv = ngx_palloc(r->pool, argc*sizeof(char *));
  63. argv_len = ngx_pcalloc(r->pool, argc*sizeof(size_t));
  64. @@ -185,10 +192,13 @@ ngx_http_rrd_graph_parse_uri(ngx_http_request_t *r, int *argc_ptr,
  65. argv[2] = p = (char *)uri_copy + clcf->name.len;
  66. argc = 3;
  67. while (*p) {
  68. - if (*p == ' ') {
  69. + if (*p == ' ' && !in_quote) {
  70. *p = '\0';
  71. argv[argc++] = p+1;
  72. } else {
  73. + if (*p == '"')
  74. + in_quote = !in_quote;
  75. +
  76. argv_len[argc-1]++;
  77. }
  78. p++;
  79. --
  80. 1.6.6.2