return NGX_OK;
}
- if (ngx_strncmp(url->data, "http://", sizeof("http://") - 1) != 0) {
+ if (url->len < sizeof("http://") - 1
+ || ngx_strncmp(url->data, "http://", sizeof("http://") - 1) != 0)
+ {
ngx_log_error(NGX_LOG_ERR, log, 0,
"js_fetch_proxy URL must use http:// scheme");
return NGX_ERROR;
js_content test.http_fetch;
}
+ location /dynamic_short_proxy {
+ set $proxy_url "http:/";
+ js_fetch_proxy $proxy_url;
+ js_content test.http_fetch;
+ }
+
location /dynamic_user_proxy {
set $proxy_url "http://$arg_user:p@127.0.0.1:%%PORT_8081%%";
js_fetch_proxy $proxy_url;
EOF
-$t->try_run('no js_fetch_proxy')->plan(4);
+$t->try_run('no js_fetch_proxy')->plan(5);
###############################################################################
'dynamic proxy URL with auth');
like(http_get('/dynamic_empty_proxy'), qr/ORIGIN:OK/,
'dynamic empty proxy URL bypasses proxy');
+like(http_get('/dynamic_short_proxy'), qr/failed to evaluate proxy URL/,
+ 'too short dynamic proxy URL is rejected');
like(http_get('/dynamic_user_proxy?user=' . ('a' x 200)),
qr/PROXY:BAD-AUTH/,
'long user in dynamic proxy URL decoded without overflow');