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

mod_dav_svn authorization configuration issue

From: YangSenhui <yangsenhui_at_21cn.com>
Date: 2006-06-26 20:06:54 CEST

Because an existing project's path contain "]",the authorization configuration don't work.
For example:
    the project contain a path name: abc[123]
    ths access configuration my be:

[test:/abc[123]/def]
samyang=rw

    But It don't work!

I think that may be parse_section_name() in subversion\libsvn_subr\config_file.c cause it.
-------------------------------------------------------------------------
/* 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 ']'.
 *
 * This is meant to be called immediately after reading the '[' that
 * starts a section name.
 */
static svn_error_t *
parse_section_name (int *pch, parse_context_t *ctx)
{
  svn_error_t *err = SVN_NO_ERROR;
  int ch;

  svn_stringbuf_setempty (ctx->section);
  for (ch = getc (ctx->fd);
       ch != EOF && ch != ']' && ch != '\n';
       ch = getc (ctx->fd))
    {
      const char char_from_int = ch;
      svn_stringbuf_appendbytes (ctx->section, &char_from_int, 1);
    }

  if (ch != ']')
    {
      ch = EOF;
      err = svn_error_createf (SVN_ERR_MALFORMED_FILE, NULL,
                               "%s:%d: Section header must end with ']'",
                               svn_path_local_style (ctx->file,
                                                     ctx->cfg->pool),
                               ctx->line);
    }
  else
    {
      /* Everything from the ']' to the end of the line is ignored. */
      ch = skip_to_eoln (ctx->fd);
      if (ch != EOF)
        ++ctx->line;
    }

  *pch = ch;
  return err;
}


My modification as following.
------------------------------------------------------------------------
/* Read chars until encounter last ']', 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 ']'.
 *
 * This is meant to be called immediately after reading the '[' that
 * starts a section name.
 */
static svn_error_t *
parse_section_name (int *pch, parse_context_t *ctx)
{
  svn_error_t *err = SVN_NO_ERROR;
  int ch;
  int counter = 0;
  apr_size_t pos = 0;

  svn_stringbuf_setempty (ctx->section);
  for (ch = getc (ctx->fd);
       ch != EOF && ch != '\n';
       ch = getc (ctx->fd))
    {
      const char char_from_int = ch;
      svn_stringbuf_appendbytes (ctx->section, &char_from_int, 1);
      if (']' == ch)
      {
         counter ++;
      }

    }

  if (!counter)
    {
      ch = EOF;
      err = svn_error_createf (SVN_ERR_MALFORMED_FILE, NULL,
                               "%s:%d: Section header must end with ']'",
                               svn_path_local_style (ctx->file,
                                                     ctx->cfg->pool),
                               ctx->line);
    }
  else
    {
      /* Everything from the last ']' to the end of the line is ignored. */
      ch = skip_to_eoln (ctx->fd);
      if (ch != EOF)
        ++ctx->line;

      pos = svn_stringbuf_find_char_backward(ctx->section, ']');
      ctx->section->data[pos] = '\0'; //risk changing svn_stringbuf struct's values.
       ctx->section->len = pos; //A better way to new a svn_stringbuf's function to do it.

    }

  *pch = ch;
  return err;
}






Received on Tue Jun 27 14:37:33 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.