[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: resolve the unicode problem of mod_authz_svn apache mod

From: L mice <hehaoslj_at_gmail.com>
Date: 2006-04-05 17:43:55 CEST

 thanks for your advice.
1. my server is Windows2003 system,when directories are [1-9a-zA-Z],it's
correct.

2.and when a repository or a directory contain chinese char. I reach a error
 [Fri Mar 31 21:16:30 2006] [error] [client 192.168.1.103] Access denied:
'hehao' CHECKOUT
testsvn:/\xe5\xa4\xa7\xe5\xae\xb6\xe5\xa5\xbd\xe6\x89\x8d\xe6\x98\xaf\xe7\x9c\x9f\xe7\x9a\x84\xe5\xa5\xbd

in python ,I do a test:
>>> import codecs
>>>
a='testsvn:/\xe5\xa4\xa7\xe5\xae\xb6\xe5\xa5\xbd\xe6\x89\x8d\xe6\x98\xaf\xe7\x9c\x9f\xe7\x9a\x84\xe5\xa5\xbd'
>>> codecs.utf_8_decode (a)[0]
u'testsvn:/\u5927\u5bb6\u597d\u624d\u662f\u771f\u7684\u597d'

3.I find out the error posted by mod_auth_svn.c ,Line 454
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                   "Access denied: '%s' %s %s",
                   r->user, r->method, repos_path);

4.I read the subversion's source code,and wanna know why the repos_path is
utf-8 encode;and how then auth apply.
here is a function call map
auth_checker
-->req_check_access-->svn_repos_authz_check_access-->authz_get_path_access-->svn_config_enumerate2
-->find_option -->svn_stringbuf_set -->svn_stringbuf_ensure

no any convert

here is the auth_conf file function call map

auth_checker-->ap_get_module_config-->req_check_acces
-->svn_repos_authz_read
-->svn_config_read-->svn_config__parse_file-->parse_section_name-->svn_stringbuf_appendbytes

no any convert

5.So,I think the Apache2 in Windows2003 convert the request's uri to utf-8.

here is the diff result:

Index: mod_authz_svn.c
> ===================================================================
> --- mod_authz_svn.c (revision 19139)
> +++ mod_authz_svn.c (working copy)
> @@ -38,6 +38,11 @@
>
> extern module AP_MODULE_DECLARE_DATA authz_svn_module;
>
> +extern
> +svn_error_t *
> +svn_utf_cstring_from_utf8 (const char **dest,
> + const char *src,
> + apr_pool_t *pool);
> typedef struct {
> int authoritative;
> int anonymous;
> @@ -108,7 +113,8 @@
> svn_error_t *svn_err;
> const char *cache_key;
> void *user_data;
> -
> + char* curi;
> + svn_error_t* convert_error;
> switch (r->method_number) {
> /* All methods requiring read access to all subtrees of r->uri */
> case M_COPY:
> @@ -144,9 +150,15 @@
> authz_svn_type |= svn_authz_write | svn_authz_recursive;
> break;
> }
> + convert_error=svn_utf_cstring_from_utf8(&curi,r->uri,r->pool);
> + if (convert_error)
> + {
> + curi = apr_pstrdup(r->pool, r->uri);
> + }
>
> dav_err = dav_svn_split_uri(r,
> - r->uri,
> + //r->uri,
> + curi,
> conf->base_path,
> &cleaned_uri,
> &trailing_slash,

 //

We generally expect people to post changes in unified diff format, the
> same thing you get from running 'svn diff'. On top of that, a clear
> description of what steps can be used to reproduce this problem, and
> why this is the correct fix would be far more likely to convince
> someone to apply it than just sending the change to the mailing list.
>
> Of the top of my head, I'm not sure this is correct, since I'd be kind
> of surprised if it's always correct that the URI you get from Apache
> is in utf8 form...
>
> -garrett
>
Received on Wed Apr 5 17:45:31 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.