Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support spaces with quotation marks around strings

  • Loading branch information...
commit a67111a39ed3505e29bfe4133e449d61e9a50679 1 parent f1a155e
Evan Miller authored
Showing with 16 additions and 4 deletions.
  1. +2 −0  README
  2. +14 −4 ngx_http_rrd_graph_module.c
View
2  README
@@ -32,6 +32,8 @@ becomes:
http://mysite.com/rrdtool--start%20now-300s%20--end%20now%20DEF%3Ads0%3Dtest.rrd%3Areading%3AAVERAGE%20LINE1%3Ads0%2300FF00
+If you need spaces in arguments, put quotation marks ("") around the string.
+
The module supports all the features of your copy of RRDtool. It can output
PNG, PDF, SVG, and EPS graphics (see the --imgformat option of rrdgraph(1)).
View
18 ngx_http_rrd_graph_module.c
@@ -151,7 +151,7 @@ static ngx_int_t
ngx_http_rrd_graph_parse_uri(ngx_http_request_t *r, int *argc_ptr,
char ***argv_ptr, size_t **argv_len_ptr)
{
- int i, argc = 3;
+ int i, argc = 3, in_quote = 0;
char **argv;
size_t *argv_len;
char *tmp, *p;
@@ -174,9 +174,16 @@ ngx_http_rrd_graph_parse_uri(ngx_http_request_t *r, int *argc_ptr,
uri_copy[r->uri.len] = '\0'; /* RRDtool needs null-terminated strings */
p = (char *)uri_copy + clcf->name.len;
- while(*p++)
- if (*p == ' ')
+ while(*p++) {
+ if (*p == '"') {
+ in_quote = !in_quote;
+ } else if (*p == ' ' && !in_quote) {
argc++;
+ }
+ }
+
+ if (in_quote)
+ return NGX_ERROR;
argv = ngx_palloc(r->pool, argc*sizeof(char *));
argv_len = ngx_pcalloc(r->pool, argc*sizeof(size_t));
@@ -185,10 +192,13 @@ ngx_http_rrd_graph_parse_uri(ngx_http_request_t *r, int *argc_ptr,
argv[2] = p = (char *)uri_copy + clcf->name.len;
argc = 3;
while (*p) {
- if (*p == ' ') {
+ if (*p == ' ' && !in_quote) {
*p = '\0';
argv[argc++] = p+1;
} else {
+ if (*p == '"')
+ in_quote = !in_quote;
+
argv_len[argc-1]++;
}
p++;
Please sign in to comment.
Something went wrong with that request. Please try again.