summaryrefslogtreecommitdiff
path: root/subversion/libsvn_subr/config_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/libsvn_subr/config_file.c')
-rw-r--r--subversion/libsvn_subr/config_file.c36
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