From 87c133d962ae7120fd4c08f25ce4f7f77078432b Mon Sep 17 00:00:00 2001 From: cozis Date: Sun, 24 Apr 2022 23:41:16 +0200 Subject: [PATCH] bug fix. Non-ASCII data in strings was reported as control characters --- xjson.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xjson.c b/xjson.c index 624eb88..90940bf 100644 --- a/xjson.c +++ b/xjson.c @@ -557,16 +557,16 @@ static void *parse_string(context_t *ctx, _Bool raw) return NULL; } - if(ctx->str[ctx->i] < 32) + if((unsigned char) ctx->str[ctx->i] > 127) { - xj_preport(ctx->error, ctx->str, ctx->i, "String contains control characters"); + xj_preport(ctx->error, ctx->str, ctx->i, "String contains non-ASCII data"); spc_free(&spc); return NULL; } - if((unsigned char) ctx->str[ctx->i] > 127) + if((unsigned char) ctx->str[ctx->i] < 32) { - xj_preport(ctx->error, ctx->str, ctx->i, "String contains non-ASCII data"); + xj_preport(ctx->error, ctx->str, ctx->i, "String contains control characters"); spc_free(&spc); return NULL; }