diff options
author | Peter Wemm <peter@FreeBSD.org> | 2013-07-28 05:04:41 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2013-07-28 05:04:41 +0000 |
commit | 97551b2898eb459e9b616947d87d026d27b61518 (patch) | |
tree | a851d66ec0c51a7321b30a677a0e55f1655af4d6 /subversion/libsvn_subr/config_file.c | |
parent | fec88c40a7bace625f49c3234a71560a161ee0ef (diff) |
Diffstat (limited to 'subversion/libsvn_subr/config_file.c')
-rw-r--r-- | subversion/libsvn_subr/config_file.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/subversion/libsvn_subr/config_file.c b/subversion/libsvn_subr/config_file.c index 9d15f6b149f80..c705b14fd40a9 100644 --- a/subversion/libsvn_subr/config_file.c +++ b/subversion/libsvn_subr/config_file.c @@ -94,7 +94,7 @@ parser_getc(parse_context_t *ctx, int *c) } else if (ctx->buffer_pos < ctx->buffer_size) { - *c = ctx->parser_buffer[ctx->buffer_pos]; + *c = (unsigned char)ctx->parser_buffer[ctx->buffer_pos]; ctx->buffer_pos++; } else @@ -107,7 +107,7 @@ parser_getc(parse_context_t *ctx, int *c) if (ctx->buffer_pos < ctx->buffer_size) { - *c = ctx->parser_buffer[ctx->buffer_pos]; + *c = (unsigned char)ctx->parser_buffer[ctx->buffer_pos]; ctx->buffer_pos++; } else @@ -131,7 +131,7 @@ parser_getc_plain(parse_context_t *ctx, int *c) { if (ctx->buffer_pos < ctx->buffer_size) { - *c = ctx->parser_buffer[ctx->buffer_pos]; + *c = (unsigned char)ctx->parser_buffer[ctx->buffer_pos]; ctx->buffer_pos++; return SVN_NO_ERROR; @@ -189,6 +189,32 @@ skip_to_eoln(parse_context_t *ctx, int *c) return SVN_NO_ERROR; } +/* Skip a UTF-8 Byte Order Mark if found. */ +static APR_INLINE svn_error_t * +skip_bom(parse_context_t *ctx) +{ + int ch; + + SVN_ERR(parser_getc(ctx, &ch)); + if (ch == 0xEF) + { + const unsigned char *buf = (unsigned char *)ctx->parser_buffer; + /* This makes assumptions about the implementation of parser_getc and + * the use of skip_bom. Specifically that parser_getc() will get all + * of the BOM characters into the parse_context_t buffer. This can + * safely be assumed as long as we only try to use skip_bom() at the + * start of the stream and the buffer is longer than 3 characters. */ + SVN_ERR_ASSERT(ctx->buffer_size > ctx->buffer_pos + 1); + if (buf[ctx->buffer_pos] == 0xBB && buf[ctx->buffer_pos + 1] == 0xBF) + ctx->buffer_pos += 2; + else + SVN_ERR(parser_ungetc(ctx, ch)); + } + else + SVN_ERR(parser_ungetc(ctx, ch)); + + return SVN_NO_ERROR; +} /* Parse a single option value */ static svn_error_t * @@ -450,6 +476,8 @@ svn_config__parse_stream(svn_config_t *cfg, svn_stream_t *stream, ctx->buffer_pos = 0; ctx->buffer_size = 0; + SVN_ERR(skip_bom(ctx)); + do { SVN_ERR(skip_whitespace(ctx, &ch, &count)); @@ -806,6 +834,8 @@ svn_config_ensure(const char *config_dir, apr_pool_t *pool) "### http-max-connections Maximum number of parallel server" NL "### connections to use for any given" NL "### HTTP operation." NL + "### http-chunked-requests Whether to use chunked transfer" NL + "### encoding for HTTP requests body." NL "### neon-debug-mask Debug mask for Neon HTTP library" NL "### ssl-authority-files List of files, each of a trusted CA" NL |