summaryrefslogtreecommitdiffhomepage
path: root/src/mail/ngx_mail_auth_http_module.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-09-22 19:15:01 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-09-22 19:15:01 +0000
commit65567a0c47415880af1099207ccdf619eda33e19 (patch)
treebc4a1fe4ec15cd67a938c885dcbea54839e38add /src/mail/ngx_mail_auth_http_module.c
parent11bb8d6c6a6d22a5c6a55ed7f100107411bf0344 (diff)
downloadnginx-65567a0c47415880af1099207ccdf619eda33e19.tar.gz
nginx-65567a0c47415880af1099207ccdf619eda33e19.tar.bz2
r1406 merge:
escape " ", "%", and %00-%1F in login and password
Diffstat (limited to 'src/mail/ngx_mail_auth_http_module.c')
-rw-r--r--src/mail/ngx_mail_auth_http_module.c36
1 files changed, 5 insertions, 31 deletions
diff --git a/src/mail/ngx_mail_auth_http_module.c b/src/mail/ngx_mail_auth_http_module.c
index 52031b340..906152ce8 100644
--- a/src/mail/ngx_mail_auth_http_module.c
+++ b/src/mail/ngx_mail_auth_http_module.c
@@ -1251,18 +1251,10 @@ ngx_mail_auth_http_create_request(ngx_mail_session_t *s, ngx_pool_t *pool,
static ngx_int_t
ngx_mail_auth_http_escape(ngx_pool_t *pool, ngx_str_t *text, ngx_str_t *escaped)
{
- u_char ch, *p;
- ngx_uint_t i, n;
+ u_char *p;
+ uintptr_t n;
- n = 0;
-
- for (i = 0; i < text->len; i++) {
- ch = text->data[i];
-
- if (ch == CR || ch == LF) {
- n++;
- }
- }
+ n = ngx_escape_uri(NULL, text->data, text->len, NGX_ESCAPE_MAIL_AUTH);
if (n == 0) {
*escaped = *text;
@@ -1276,27 +1268,9 @@ ngx_mail_auth_http_escape(ngx_pool_t *pool, ngx_str_t *text, ngx_str_t *escaped)
return NGX_ERROR;
}
- escaped->data = p;
-
- for (i = 0; i < text->len; i++) {
- ch = text->data[i];
-
- if (ch == CR) {
- *p++ = '%';
- *p++ = '0';
- *p++ = 'D';
- continue;
- }
+ (void) ngx_escape_uri(p, text->data, text->len, NGX_ESCAPE_MAIL_AUTH);
- if (ch == LF) {
- *p++ = '%';
- *p++ = '0';
- *p++ = 'A';
- continue;
- }
-
- *p++ = ch;
- }
+ escaped->data = p;
return NGX_OK;
}