On Thursday 10 February 2011 12:48 PM, Arwin Arni wrote:
On Wednesday 09 February 2011 09:21 PM, Arwin Arni wrote:
Hi All,
Here's the patch for the implementation of the logic.
Regards,
Arwin Arni
Sorry, Please ignore the previous patch. There was a stray caller of
svn_config_create (whose signature I changed and didn't rev as it was
new in the 1.7 API.). Here's the correct patch.
Regards,
Arwin Arni
I missed adding the documentation for the deviation in behavior for
SVN_CONFIG__DEFAULT_SECTION. So here is a patch with the documentation.
This is the last correction. I promise.
Regards,
Arwin Arni
Index: subversion/tests/cmdline/authz_tests.py
===================================================================
--- subversion/tests/cmdline/authz_tests.py (revision 1069239)
+++ subversion/tests/cmdline/authz_tests.py (working copy)
@@ -1084,7 +1084,6 @@
[], 'ls', '-R',
sbox.repo_url)
-@XFail()
@Issue(3781)
@Skip(svntest.main.is_ra_type_file)
def case_sensitive_authz(sbox):
Index: subversion/include/svn_config.h
===================================================================
--- subversion/include/svn_config.h (revision 1069239)
+++ subversion/include/svn_config.h (working copy)
@@ -189,10 +189,14 @@
/** Set @a *cfgp to an empty @c svn_config_t structure,
* allocated in @a result_pool.
*
+ * Pass TRUE to @a section_names_case_sensitive if
+ * section names are to be populated case sensitively.
+ *
* @since New in 1.7.
*/
svn_error_t *
svn_config_create(svn_config_t **cfgp,
+ svn_boolean_t section_names_case_sensitive,
apr_pool_t *result_pool);
/** Read configuration data from @a file (a file or registry path) into
@@ -200,8 +204,27 @@
*
* If @a file does not exist, then if @a must_exist, return an error,
* otherwise return an empty @c svn_config_t.
+ *
+ * If @a section_names_case_sensitive is TRUE, populate section name hashes
+ * case sensitively. Except for the default SVN_CONFIG__DEFAULT_SECTION.
+ *
+ * @since New in 1.7.
*/
+
svn_error_t *
+svn_config_read2(svn_config_t **cfgp,
+ const char *file,
+ svn_boolean_t must_exist,
+ svn_boolean_t section_names_case_sensitive,
+ apr_pool_t *pool);
+
+/** Similar to svn_config_read2, but always passes FALSE to
+ * section_names_case_sensitive.
+ *
+ * @deprecated Provided for backward compatibility with 1.6 API.
+ */
+SVN_DEPRECATED
+svn_error_t *
svn_config_read(svn_config_t **cfgp,
const char *file,
svn_boolean_t must_exist,
Index: subversion/libsvn_subr/config_impl.h
===================================================================
--- subversion/libsvn_subr/config_impl.h (revision 1069239)
+++ subversion/libsvn_subr/config_impl.h (working copy)
@@ -63,6 +63,9 @@
/* Temporary value used for expanded default values in svn_config_get.
(Using a stringbuf so that frequent resetting is efficient.) */
svn_stringbuf_t *tmp_value;
+
+ /* Specifies whether section names are populated case sensitively. */
+ svn_boolean_t section_names_case_sensitive;
};
Index: subversion/libsvn_subr/deprecated.c
===================================================================
--- subversion/libsvn_subr/deprecated.c (revision 1069239)
+++ subversion/libsvn_subr/deprecated.c (working copy)
@@ -1064,3 +1064,16 @@
start, end, TRUE,
pool, pool));
}
+
+/*** From config.c ***/
+
+svn_error_t *
+svn_config_read(svn_config_t **cfgp, const char *file,
+ svn_boolean_t must_exist,
+ apr_pool_t *pool)
+{
+ return svn_error_return(svn_config_read2(cfgp, file,
+ must_exist,
+ FALSE,
+ pool));
+}
Index: subversion/libsvn_subr/config.c
===================================================================
--- subversion/libsvn_subr/config.c (revision 1069239)
+++ subversion/libsvn_subr/config.c (working copy)
@@ -78,7 +78,9 @@
svn_error_t *
-svn_config_create(svn_config_t **cfgp, apr_pool_t *result_pool)
+svn_config_create(svn_config_t **cfgp,
+ svn_boolean_t section_names_case_sensitive,
+ apr_pool_t *result_pool)
{
svn_config_t *cfg = apr_palloc(result_pool, sizeof(*cfg));
@@ -88,19 +90,22 @@
cfg->x_values = FALSE;
cfg->tmp_key = svn_stringbuf_create("", result_pool);
cfg->tmp_value = svn_stringbuf_create("", result_pool);
-
+ cfg->section_names_case_sensitive = section_names_case_sensitive;
+
*cfgp = cfg;
return SVN_NO_ERROR;
}
svn_error_t *
-svn_config_read(svn_config_t **cfgp, const char *file,
- svn_boolean_t must_exist, apr_pool_t *pool)
+svn_config_read2(svn_config_t **cfgp, const char *file,
+ svn_boolean_t must_exist,
+ svn_boolean_t section_names_case_sensitive,
+ apr_pool_t *pool)
{
svn_config_t *cfg;
svn_error_t *err;
- SVN_ERR(svn_config_create(&cfg, pool));
+ SVN_ERR(svn_config_create(&cfg, section_names_case_sensitive, pool));
/* Yes, this is platform-specific code in Subversion, but there's no
practical way to migrate it into APR, as it's simultaneously
@@ -387,7 +392,8 @@
/* Canonicalize the hash key */
svn_stringbuf_set(cfg->tmp_key, section);
- make_hash_key(cfg->tmp_key->data);
+ if (! cfg->section_names_case_sensitive)
+ make_hash_key(cfg->tmp_key->data);
sec_ptr = apr_hash_get(cfg->sections, cfg->tmp_key->data,
cfg->tmp_key->len);
@@ -618,7 +624,10 @@
/* Even the section doesn't exist. Create it. */
sec = apr_palloc(cfg->pool, sizeof(*sec));
sec->name = apr_pstrdup(cfg->pool, section);
- sec->hash_key = make_hash_key(apr_pstrdup(cfg->pool, section));
+ if(cfg->section_names_case_sensitive)
+ sec->hash_key = sec->name;
+ else
+ sec->hash_key = make_hash_key(apr_pstrdup(cfg->pool, section));
sec->options = apr_hash_make(cfg->pool);
apr_hash_set(cfg->sections, sec->hash_key, APR_HASH_KEY_STRING, sec);
}
Index: subversion/libsvn_repos/authz.c
===================================================================
--- subversion/libsvn_repos/authz.c (revision 1069239)
+++ subversion/libsvn_repos/authz.c (working copy)
@@ -746,7 +746,7 @@
baton.err = SVN_NO_ERROR;
/* Load the rule file. */
- SVN_ERR(svn_config_read(&authz->cfg, file, must_exist, pool));
+ SVN_ERR(svn_config_read2(&authz->cfg, file, must_exist, TRUE, pool));
baton.config = authz->cfg;
/* Step through the entire rule file, stopping on error. */
Index: subversion/tests/cmdline/atomic-ra-revprop-change.c
===================================================================
--- subversion/tests/cmdline/atomic-ra-revprop-change.c (revision 1069239)
+++ subversion/tests/cmdline/atomic-ra-revprop-change.c (working copy)
@@ -119,7 +119,7 @@
svn_config_t *servers;
/* Populate SERVERS. */
- SVN_ERR(svn_config_create(&servers, pool));
+ SVN_ERR(svn_config_create(&servers, FALSE, pool));
svn_config_set(servers, SVN_CONFIG_SECTION_GLOBAL,
SVN_CONFIG_OPTION_HTTP_LIBRARY, http_library);
Fix Issue #3781 (Case sensitive authz).
* subversion/tests/cmdline/authz_tests.py
(case_sensitive_authz): Removed XFail decorator.
* subversion/include/svn_config.h
(svn_config_create) : Documented new parameter.
(svn_config_read) : Deprecated.
(svn_config_read2) : New function prototype, updated documentation.
* subversion/libsvn_subr/config_impl.h
(svn_config_t): Added a new boolean called section_names_case_sensitive.
* subversion/libsvn_subr/deprecated.c
(svn_config_read): New function that calls svn_config_read2
with section_names_case_sensitive as FALSE.
* subversion/libsvn_subr/config.c
(svn_config_create): Added a parameter section_names_case_sensitive
which is used to initialize the config.
(find_option,
svn_config_set) : Added logic to make section names case sensitive.
(svn_config_read) : Deprecated.
(svn_config_read2) : New function that deprecates svn_config_read.
Accepts a boolean section_names_case_sensitive,
and populates the section names case sensitively
if TRUE.
* subversion/libsvn_repos/authz.c
(svn_repos_authz_read) : Fixed the caller with
section_names_case_sensitive as TRUE.
* subversion/tests/cmdline/atomic-ra-revprop-change.c
(construct_config) : Fixed call of svn_config_create.
Patch by: Arwin Arni <arwin{_AT_}collab.net>