author | Junio C Hamano <gitster@pobox.com> | |
Tue, 14 Dec 2010 15:35:18 +0000 (07:35 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 14 Dec 2010 15:35:18 +0000 (07:35 -0800) |
* gc/http-with-non-ascii-username-url:
Fix username and password extraction from HTTP URLs
t5550: test HTTP authentication and userinfo decoding
Conflicts:
t/lib-httpd/apache.conf
Fix username and password extraction from HTTP URLs
t5550: test HTTP authentication and userinfo decoding
Conflicts:
t/lib-httpd/apache.conf
1 | 2 | |||
---|---|---|---|---|
http.c | patch | | diff1 | | diff2 | | blob | history |
t/lib-httpd/apache.conf | patch | | diff1 | | diff2 | | blob | history |
diff --combined http.c
index 17bcf19c5001d309bdbf524e7d3817cf3482a3c3,c9393a84715aa543938b9c4f934186334486daae..f582b13b915e58a189086cdec2bab6dbb94eac6a
+++ b/http.c
#include "pack.h"
#include "sideband.h"
#include "run-command.h"
+ #include "url.h"
int data_received;
int active_requests;
}
curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
+#if LIBCURL_VERSION_NUM >= 0x071301
+ curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
+#elif LIBCURL_VERSION_NUM >= 0x071101
+ curl_easy_setopt(result, CURLOPT_POST301, 1);
+#endif
if (getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
static void http_auth_init(const char *url)
{
- char *at, *colon, *cp, *slash;
+ char *at, *colon, *cp, *slash, *decoded;
int len;
cp = strstr(url, "://");
user_name = xmalloc(len + 1);
memcpy(user_name, cp, len);
user_name[len] = '\0';
+ decoded = url_decode(user_name);
+ free(user_name);
+ user_name = decoded;
user_pass = NULL;
} else {
len = colon - cp;
user_name = xmalloc(len + 1);
memcpy(user_name, cp, len);
user_name[len] = '\0';
+ decoded = url_decode(user_name);
+ free(user_name);
+ user_name = decoded;
len = at - (colon + 1);
user_pass = xmalloc(len + 1);
memcpy(user_pass, colon + 1, len);
user_pass[len] = '\0';
+ decoded = url_decode(user_pass);
+ free(user_pass);
+ user_pass = decoded;
}
}
diff --combined t/lib-httpd/apache.conf
index f41c7c674c497825d714a0fe9be3c9bc0a0f30c6,b40e43bb311dd6f5088c0eb2ea8d1e67214f130f..0a4cdfa93ece7d8a4177835b5569583c22303564
+++ b/t/lib-httpd/apache.conf
<IfModule !mod_env.c>
LoadModule env_module modules/mod_env.so
</IfModule>
+<IfModule !mod_rewrite.c>
+ LoadModule rewrite_module modules/mod_rewrite.so
+</IFModule>
+ <IfModule !mod_version.c>
+ LoadModule version_module modules/mod_version.so
+ </IfModule>
+
+ <IfVersion < 2.1>
+ <IfModule !mod_auth.c>
+ LoadModule auth_module modules/mod_auth.so
+ </IfModule>
+ </IfVersion>
+
+ <IfVersion >= 2.1>
+ <IfModule !mod_auth_basic.c>
+ LoadModule auth_basic_module modules/mod_auth_basic.so
+ </IfModule>
+ <IfModule !mod_authn_file.c>
+ LoadModule authn_file_module modules/mod_authn_file.so
+ </IfModule>
+ <IfModule !mod_authz_user.c>
+ LoadModule authz_user_module modules/mod_authz_user.so
+ </IfModule>
+ </IfVersion>
Alias /dumb/ www/
+ Alias /auth/ www/auth/
<Location /smart/>
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
Options ExecCGI
</Files>
+RewriteEngine on
+RewriteRule ^/smart-redir-perm/(.*)$ /smart/$1 [R=301]
+RewriteRule ^/smart-redir-temp/(.*)$ /smart/$1 [R=302]
+
<IfDefine SSL>
LoadModule ssl_module modules/mod_ssl.so
SSLEngine On
</IfDefine>
+ <Location /auth/>
+ AuthType Basic
+ AuthName "git-auth"
+ AuthUserFile passwd
+ Require valid-user
+ </Location>
+
<IfDefine DAV>
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so