nginx-0.3.22-RELEASE import
*) Feature: the ngx_http_perl_module supports the $r->args and
$r->unescape methods.
*) Feature: the method $r->query_string of ngx_http_perl_module was
canceled.
*) Bugfix: segmentation fault was occurred if the "none" or "blocked"
values was specified in the "valid_referers" directive; the bug had
appeared in 0.3.18.
diff --git a/src/core/nginx.c b/src/core/nginx.c
index d30e127..a9a0dd9 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -168,6 +168,8 @@
ngx_uint_t ngx_max_module;
+static char *ngx_null_environ = NULL;
+
int ngx_cdecl
main(int argc, char *const *argv)
@@ -232,6 +234,8 @@
return 1;
}
+ environ = &ngx_null_environ;
+
ngx_max_module = 0;
for (i = 0; ngx_modules[i]; i++) {
ngx_modules[i]->index = ngx_max_module++;
diff --git a/src/core/nginx.h b/src/core/nginx.h
index ec125d6..a2c696f 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VER "nginx/0.3.21"
+#define NGINX_VER "nginx/0.3.22"
#define NGINX_VAR "NGINX"
#define NGX_OLDPID_EXT ".oldbin"
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c
index 2bb335a..c99778d 100644
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -931,7 +931,7 @@
void
-ngx_unescape_uri(u_char **dst, u_char **src, size_t size)
+ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type)
{
u_char *d, *s, ch, c, decoded;
enum {
@@ -952,7 +952,7 @@
switch (state) {
case sw_usual:
- if (ch == '?') {
+ if (ch == '?' && type == NGX_UNESCAPE_URI) {
*d++ = ch;
goto done;
}
@@ -995,12 +995,18 @@
if (ch >= '0' && ch <= '9') {
ch = (u_char) ((decoded << 4) + ch - '0');
- if (ch > '%' && ch < 0x7f) {
- *d++ = ch;
+ if (type == NGX_UNESCAPE_URI) {
+ if (ch > '%' && ch < 0x7f) {
+ *d++ = ch;
+ break;
+ }
+
+ *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
+
break;
}
- *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
+ *d++ = ch;
break;
}
@@ -1009,17 +1015,22 @@
if (c >= 'a' && c <= 'f') {
ch = (u_char) ((decoded << 4) + c - 'a' + 10);
- if (ch == '?') {
- *d++ = ch;
- goto done;
- }
+ if (type == NGX_UNESCAPE_URI) {
+ if (ch == '?') {
+ *d++ = ch;
+ goto done;
+ }
- if (ch > '%' && ch < 0x7f) {
- *d++ = ch;
+ if (ch > '%' && ch < 0x7f) {
+ *d++ = ch;
+ break;
+ }
+
+ *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
break;
}
- *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
+ *d++ = ch;
break;
}
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index 0192a30..d76a0f5 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -144,13 +144,15 @@
u_char * ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n);
-#define NGX_ESCAPE_URI 0
-#define NGX_ESCAPE_ARGS 1
-#define NGX_ESCAPE_HTML 2
+#define NGX_ESCAPE_URI 0
+#define NGX_ESCAPE_ARGS 1
+#define NGX_ESCAPE_HTML 2
+
+#define NGX_UNESCAPE_URI 1
uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size,
ngx_uint_t type);
-void ngx_unescape_uri(u_char **dst, u_char **src, size_t size);
+void ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type);
#define ngx_qsort qsort
diff --git a/src/http/modules/ngx_http_referer_module.c b/src/http/modules/ngx_http_referer_module.c
index 0d3ee6f..459984e 100644
--- a/src/http/modules/ngx_http_referer_module.c
+++ b/src/http/modules/ngx_http_referer_module.c
@@ -90,10 +90,7 @@
rlcf = ngx_http_get_module_loc_conf(r, ngx_http_referer_module);
- if (rlcf->hash.buckets == NULL
- && rlcf->dns_wildcards == NULL
- && rlcf->dns_wildcards->hash.buckets == NULL)
- {
+ if (rlcf->hash.buckets == NULL && rlcf->dns_wildcards == NULL) {
goto valid;
}
@@ -145,7 +142,7 @@
}
}
- if (rlcf->dns_wildcards && rlcf->dns_wildcards->hash.buckets) {
+ if (rlcf->dns_wildcards) {
uri = ngx_hash_find_wildcard(rlcf->dns_wildcards, buf, len);
if (uri) {
goto uri;
diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm
index 66ff64f..c0f3f27 100644
--- a/src/http/modules/perl/nginx.pm
+++ b/src/http/modules/perl/nginx.pm
@@ -17,7 +17,7 @@
HTTP_SERVER_ERROR
);
-our $VERSION = '0.3.21';
+our $VERSION = '0.3.22';
require XSLoader;
XSLoader::load('nginx', $VERSION);
@@ -48,11 +48,6 @@
This module provides a Perl interface to the nginx HTTP server API.
-=head2 EXPORT
-
-None by default.
-
-
=head1 SEE ALSO
diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs
index 21d2deb..d41bf68 100644
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -156,13 +156,13 @@
char *
-query_string(r, ...)
+args(r, ...)
nginx r
CODE:
if (items != 1) {
- croak("$r->query_string(text) is not implemented");
+ croak("$r->args(text) is not implemented");
}
RETVAL = ngx_palloc(r->pool, r->args.len + 1);
@@ -360,6 +360,9 @@
b->start = p;
b->end = b->last;
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "$r->print: read-only SV: %z", len);
+
goto out;
}
}
@@ -374,12 +377,11 @@
sv = SvRV(sv);
}
- ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "SV: %p %d %Xd",
- sv, SvREFCNT(sv), SvREADONLY(sv));
-
(void) SvPV(sv, len);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "$r->print: copy SV: %z", len);
+
size += len;
}
@@ -513,6 +515,8 @@
b->flush = 1;
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "$r->rflush");
+
RETVAL = ngx_http_perl_output(r, b);
done:
@@ -549,3 +553,34 @@
XSRETURN_EMPTY;
}
}
+
+
+char *
+unescape(r, text, type = 0)
+ nginx r
+ SV *text
+ int type
+
+ PREINIT:
+
+ u_char *p, *dst, *src;
+ STRLEN n;
+
+ CODE:
+
+ src = (u_char *) SvPV(text, n);
+
+ p = ngx_palloc(r->pool, n + 1);
+ if (p == NULL) {
+ XSRETURN_UNDEF;
+ }
+
+ dst = p;
+
+ ngx_unescape_uri(&dst, &src, n, (ngx_uint_t) type);
+ *dst = '\0';
+
+ RETVAL = (char *) p;
+
+ OUTPUT:
+ RETVAL
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index 4986675..b46c9bb 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -682,7 +682,7 @@
dst = e->buf.data;
src = e->buf.data;
- ngx_unescape_uri(&dst, &src, e->pos - e->buf.data);
+ ngx_unescape_uri(&dst, &src, e->pos - e->buf.data, NGX_UNESCAPE_URI);
if (src < e->pos) {
dst = ngx_copy(dst, src, e->pos - src);
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
index 73deb9c..c187191 100644
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -97,9 +97,11 @@
#endif
-extern char *malloc_options;
-
#define NGX_HAVE_OS_SPECIFIC_INIT 1
+extern char **environ;
+extern char *malloc_options;
+
+
#endif /* _NGX_FREEBSD_CONFIG_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index ac7d7a8..74bbfb1 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -101,4 +101,7 @@
#define NGX_HAVE_OS_SPECIFIC_INIT 1
+extern char **environ;
+
+
#endif /* _NGX_LINUX_CONFIG_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_posix_config.h b/src/os/unix/ngx_posix_config.h
index dc4341a..984db96 100644
--- a/src/os/unix/ngx_posix_config.h
+++ b/src/os/unix/ngx_posix_config.h
@@ -102,4 +102,7 @@
#endif
+extern char **environ;
+
+
#endif /* _NGX_POSIX_CONFIG_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h
index a668b95..ba1d351 100644
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -88,4 +88,7 @@
#define NGX_HAVE_OS_SPECIFIC_INIT 1
+extern char **environ;
+
+
#endif /* _NGX_SOLARIS_CONFIG_H_INCLUDED_ */