From bee33cfc4127ae3b35ad23ddbcbd0c047728a1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Wed, 22 May 2024 13:54:13 +0200 Subject: [PATCH] Fix spaces removal on digests with control chars Compression of multiple spaces into one should apply to every character that is considered a space by `is_space_char`. --- lib/c_tokenizer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/c_tokenizer.cpp b/lib/c_tokenizer.cpp index 5b35ef0fb..3c3fdc132 100644 --- a/lib/c_tokenizer.cpp +++ b/lib/c_tokenizer.cpp @@ -1267,10 +1267,10 @@ void stage_1_parsing(shared_st* shared_st, stage_1_st* stage_1_st, options* opts // Q: `SELECT\s\s 1` // ^ address used to be replaced by next char // ``` - if (shared_st->prev_char == ' ' && is_space_char(*shared_st->q)) { + if (is_space_char(shared_st->prev_char) && is_space_char(*shared_st->q)) { // if current position in result buffer is the first space found, we move to the next // position, in order to respect the first space char. - if (*(shared_st->res_cur_pos-1) != ' ') { + if (!is_space_char(*(shared_st->res_cur_pos-1))) { shared_st->res_cur_pos++; } @@ -2400,10 +2400,10 @@ char* mysql_query_digest_and_first_comment_one_it(char* q, int q_len, char** fst // Q: `SELECT\s\s 1` // ^ address used to be replaced by next char // ``` - if (shared_st.prev_char == ' ' && is_space_char(*shared_st.q)) { + if (is_space_char(shared_st.prev_char) && is_space_char(*shared_st.q)) { // if current position in result buffer is the first space found, we move to the next // position, in order to respect the first space char. - if (*(shared_st.res_cur_pos-1) != ' ') { + if (!is_space_char(*(shared_st.res_cur_pos-1))) { shared_st.res_cur_pos++; }