SQUIDCEXTERN char *rfc1738_escape_part(const char *);
SQUIDCEXTERN void rfc1738_unescape(char *);
+/* charset.c */
+SQUIDCEXTERN char *latin1_to_utf8(char *out, size_t size, const char *in);
+
/* html.c */
SQUIDCEXTERN char *html_quote(const char *);
libmiscutil_a_SOURCES = \
MemPool.cc \
base64.c \
+ charset.c \
getfullhostname.c \
hash.c \
heap.c \
--- /dev/null
+/*
+ * $Id: charset.c,v 1.1 2008/07/07 11:04:47 hno Exp $
+ *
+ * DEBUG:
+ * AUTHOR: Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * Copyright (C) 2008 Henrik Nordstrom
+ *
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#include "config.h"
+#include "util.h"
+
+/* Convert ISO-LATIN-1 to UTF-8
+ */
+char *
+latin1_to_utf8(char *out, size_t size, const char *in)
+{
+ unsigned char *p;
+ for (p = (unsigned char *)out; *in && size > 2; in++) {
+ unsigned char ch = (unsigned char)*in;
+ if (ch < 0x80) {
+ *p++ = ch;
+ size--;
+ } else {
+ *p++ = (ch >> 6) | 0xc0;
+ size--;
+ *p++ = (ch & 0x3f) | 0x80;
+ size--;
+ }
+ }
+ *p++ = '\0';
+ if (*in)
+ return NULL;
+ return out;
+}
+
+
parse_time_t(&credentialsTTL);
} else if (strcasecmp(param_str, "casesensitive") == 0) {
parse_onoff(&casesensitive);
+ } else if (strcasecmp(param_str, "utf8") == 0) {
+ parse_onoff(&utf8);
} else {
debugs(29, DBG_CRITICAL, HERE << "unrecognised basic auth scheme parameter '" << param_str << "'");
}
r->handler = handler;
r->data = cbdataReference(data);
r->auth_user_request = auth_user_request;
- xstrncpy(user, rfc1738_escape(username()), sizeof(user));
- xstrncpy(pass, rfc1738_escape(passwd), sizeof(pass));
+ if (basicConfig.utf8) {
+ latin1_to_utf8(user, sizeof(user), username());
+ latin1_to_utf8(pass, sizeof(pass), passwd);
+ xstrncpy(user, rfc1738_escape(user), sizeof(user));
+ xstrncpy(pass, rfc1738_escape(pass), sizeof(pass));
+ } else {
+ xstrncpy(user, rfc1738_escape(username()), sizeof(user));
+ xstrncpy(pass, rfc1738_escape(passwd), sizeof(pass));
+ }
snprintf(buf, sizeof(buf), "%s %s\n", user, pass);
helperSubmit(basicauthenticators, buf, authenticateBasicHandleReply, r);
}
wordlist *authenticate;
time_t credentialsTTL;
int casesensitive;
+ int utf8;
};
#endif
parse_onoff(&CheckNonceCount);
} else if (strcasecmp(param_str, "post_workaround") == 0) {
parse_onoff(&PostWorkaround);
+ } else if (strcasecmp(param_str, "utf8") == 0) {
+ parse_onoff(&utf8);
} else {
debugs(29, 0, "unrecognised digest auth scheme parameter '" << param_str << "'");
}
r->data = cbdataReference(data);
r->auth_user_request = this;
AUTHUSERREQUESTLOCK(r->auth_user_request, "r");
- snprintf(buf, 8192, "\"%s\":\"%s\"\n", digest_user->username(), realm);
+ if (digestConfig.utf8) {
+ char user[1024];
+ latin1_to_utf8(user, sizeof(user), digest_user->username());
+ snprintf(buf, 8192, "\"%s\":\"%s\"\n", user, realm);
+ } else {
+ snprintf(buf, 8192, "\"%s\":\"%s\"\n", digest_user->username(), realm);
+ }
helperSubmit(digestauthenticators, buf, authenticateDigestHandleReply, r);
}
int NonceStrictness;
int CheckNonceCount;
int PostWorkaround;
+ int utf8;
};
typedef class AuthDigestConfig auth_digest_config;