Skip to content

Commit

Permalink
bugfix: the callback argument value parser did not accept JS identifi…
Browse files Browse the repository at this point in the history
…er names started with underscores. thanks Sam Mulube.
  • Loading branch information
agentzh committed Nov 4, 2011
1 parent fb5ea7e commit 769ce1c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -52,3 +52,4 @@ src/util.c
src/util.rl
all
t/servroot/
buildroot/
8 changes: 5 additions & 3 deletions src/ngx_http_xss_util.c
Expand Up @@ -40,8 +40,10 @@ ngx_int_t ngx_http_xss_test_callback(char *data, size_t len)
if ( ++p == pe )
goto _test_eof1;
case 1:
if ( (*p) == 36 )
goto st6;
switch( (*p) ) {
case 36: goto st6;
case 95: goto st6;
}
if ( (*p) > 90 ) {
if ( 97 <= (*p) && (*p) <= 122 )
goto st6;
Expand Down Expand Up @@ -128,7 +130,7 @@ case 5:


if (cs <
#line 132 "src/ngx_http_xss_util.c"
#line 134 "src/ngx_http_xss_util.c"
6
#line 29 "src/ngx_http_xss_util.rl"
|| p != pe) {
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_xss_util.rl
Expand Up @@ -13,7 +13,7 @@ ngx_int_t ngx_http_xss_test_callback(char *data, size_t len)
int cs;

%%{
identifier = [$A-Za-z] [$A-Za-z0-9_]*;
identifier = [$A-Za-z_] [$A-Za-z0-9_]*;

index = [0-9]* '.' [0-9]+
| [0-9]+
Expand Down
18 changes: 18 additions & 0 deletions t/sanity.t
Expand Up @@ -261,3 +261,21 @@ blah(hello);
--- response_headers
Content-Type: application/x-javascript
=== TEST 4: bug: keys started by underscore
--- config
location /foo {
default_type 'application/json';
xss_get on;
xss_callback_arg _callback;
echo '[]';
}
--- request
GET /foo?_callback=foo._bar
--- response_headers_like
Content-Type: application/x-javascript
--- response_body chop
foo._bar([]
);

0 comments on commit 769ce1c

Please sign in to comment.