Josh Siegel wrote:
>
> After extensive conversations in irc yesterday as well as via private
> email, I rewrote the mod_authz_svn changes to use the pcre library out
> of apache2. So, there are two questions that need to be resolved.
> First, section header parsing
> (libsvn_subr/config_file.c:parse_section_name)
>
> [repos:/foo/[^/]+/]
>
> Right now if ] is anywhere but at the end, it emits a "Section header
> must end with ']'" error. Should we modify it to do a greedy match
> till it finds a "]\s*\n"? the perl expression would be: [(.*)]\s*\n?
I think this would be a relatively safe thing to do in the config
parser. The attached patch (untested) should do it.
I'm a bit worried about the case-insensitive nature of the section and
option names. Mea culpa, I designed that interface and didn't realise at
the time that this was a mistake. Maybe we can silently change that to
case-sensitive... formally, we couldn't do this before 2.0.
[[[
Change the svn_config parser allow '[' and ']' in section names.
* subversion/libsvn_subr/config_file.c (parse_section_name):
Don't end the section name at the first ']', look for the
last ']' instead but allow only whitespace from there to
the end of the line.
]]]
Index: config_file.c
===================================================================
--- config_file.c (revision 13049)
+++ config_file.c (working copy)
@@ -211,11 +211,11 @@
}
-/* Read chars until enounter ']', then skip everything to the end of
- * the line. Set *PCH to the character that ended the line (either
- * newline or EOF), and set CTX->section to the string of characters
- * seen before ']'.
- *
+/* Read chars until the last ']' in the line, then skip whitespace to
+ * the end of the line. Set *PCH to the character that ended the line
+ * (either newline or EOF), and set CTX->section to the string of
+ * characters seen before ']'.
+ *
* This is meant to be called immediately after reading the '[' that
* starts a section name.
*/
@@ -223,18 +223,32 @@
parse_section_name (int *pch, parse_context_t *ctx)
{
svn_error_t *err = SVN_NO_ERROR;
+ svn_boolean_t bracket = FALSE;
+ svn_boolean_t nonspace = FALSE;
+ apr_size_t bracket_col = 0;
+ apr_size_t column = 0;
int ch;
svn_stringbuf_setempty (ctx->section);
for (ch = getc (ctx->fd);
- ch != EOF && ch != ']' && ch != '\n';
- ch = getc (ctx->fd))
+ ch != EOF && && ch != '\n';
+ ch = getc (ctx->fd), ++column)
{
const char char_from_int = ch;
svn_stringbuf_appendbytes (ctx->section, &char_from_int, 1);
+ if (ch == ']')
+ {
+ /* bracket_col and bracket must be separate, because empty
+ section names are allowed. */
+ bracket_col = column;
+ bracket = TRUE;
+ nonspace = FALSE;
+ }
+ else if (bracket && !apr_isspace (ch))
+ nonspace = TRUE;
}
- if (ch != ']')
+ if (!bracket || nonspace)
{
ch = EOF;
err = svn_error_createf (SVN_ERR_MALFORMED_FILE, NULL,
@@ -245,8 +259,7 @@
}
else
{
- /* Everything from the ']' to the end of the line is ignored. */
- ch = skip_to_eoln (ctx->fd);
+ svn_stringbuf_chop (ctx->section, column - backet_col + 1);
if (ch != EOF)
++ctx->line;
}
-- Brane
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Feb 18 19:13:50 2005