Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s4S17-0043gG-Eb for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2024 21:06:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s4S14-005FXD-Vi for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2024 21:06:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s4S14-005FX5-LJ for pgsql-hackers@lists.postgresql.org; Tue, 07 May 2024 21:06:27 +0000 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s4S10-001vb1-Dz for pgsql-hackers@postgresql.org; Tue, 07 May 2024 21:06:25 +0000 Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3c968f64cdeso937762b6e.0 for ; Tue, 07 May 2024 14:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1715115981; x=1715720781; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xPxFVDFc2EYv/N9HiIaw2H5ePeGAGNTx/8S09uOA0HU=; b=ZCArwYpSuWSEfI7o7XYGUaWaMSzlGQhCwUI6LznYaivWRuS+CpGdfP79IqNLWdt8R2 BX5Vpkkz4/t/A5wHXGhcW/z5g7vqGIGAkgnHYlddUnl9a9CR/pASriPNdYc7Bdls3XJG rJQhD4tKYjpuXriE5Xr/3pw0PfkhvGQIO+Cmr//VcwZkfb+3DQWZYMryJxnWox7hau3N c7xPh81tAwK+G3KUagYsKS8k2VVEzW9BYcCCq7kuKWW+7xrCGpGHXYWQCNr8tGLnStkq 8tycyz/OG5Lnw83Lk1GAO1IcUSSJog0lsB0t/wAceuA4ewOW7Rj2SyQ+wRvDIzUf1OIM tE8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715115981; x=1715720781; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xPxFVDFc2EYv/N9HiIaw2H5ePeGAGNTx/8S09uOA0HU=; b=piCku49r/RDbMs1Hn7xwK2Yn+VMYPeWFpCmU651hsQflbs1qEPFhBpkrJb4kXbL1Gm Lbf8tDF2cTX3VcRPJN4QPyChVB+PT11dqqYB2nVFyLgPSJvzNJr8McbIBzvBwbqCvUbM yzFkEbBAzhKF7hnopmj7u5T/7RUNigJwWwIO/ptTCV3VA7fErCb5g638PN/JrJ7f2M8h NNPKlZs7cLmUz02coAH+7WO3YOwPpaGBBBUptZkUm2hUDka3VBKx+tOXJHjKKKaBhvDC VXRCzOKCE7FKhIFngQg56nQ6HqOiDafuyxnRT3b7auLXkCB9otGU91WoxfBuutWUjuLR BEWA== X-Forwarded-Encrypted: i=1; AJvYcCViUNaMaHsFgp9ydIT2ivV/R3fl7qD+yYsQpFSRFgC6mxGGUfY9mbTcs+jUXQ9mcV7Td4gpw05IP2DH/Wr7TQKwCA1SbjnTYApjjv5g X-Gm-Message-State: AOJu0YyJ9FksKu5hm1yM7BkqlnojBoQraeLcEc+NojErD2emrnnpZNxg yjU/tcmzbrJviMr7xoQquVvUaEpplMop7UNtG/xAxOlNKF1z18vZiGOgwNOdw1s9sg9EIAs9Khl HOqukSdrtCsOY6/4F9vgS5WT3Dl1lTLt6RgATChrFGU2KM9Y= X-Google-Smtp-Source: AGHT+IEZJdT5vChWhU/aH6dJjz0kHiHtIcB2qnfCTWvJlg2HyLpJGSzorsPUYvP0tuWCYx4QJBm4EZPRQeWfyZ1mrU0= X-Received: by 2002:a05:6808:a8d:b0:3c7:999:f5d9 with SMTP id 5614622812f47-3c9852bd66fmr875428b6e.15.1715115980989; Tue, 07 May 2024 14:06:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jacob Champion Date: Tue, 7 May 2024 14:06:10 -0700 Message-ID: Subject: Re: [PATCH] json_lex_string: don't overread on bad UTF8 To: Michael Paquier Cc: Peter Eisentraut , PostgreSQL Hackers , Andrew Dunstan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, May 6, 2024 at 8:43=E2=80=AFPM Michael Paquier wrote: > On Fri, May 03, 2024 at 07:05:38AM -0700, Jacob Champion wrote: > > We could port something like that to src/common. IMO that'd be more > > suited for an actual conversion routine, though, as opposed to a > > parser that for the most part assumes you didn't lie about the input > > encoding and is just trying not to crash if you're wrong. Most of the > > time, the parser just copies bytes between delimiters around and it's > > up to the caller to handle encodings... the exceptions to that are the > > \uXXXX escapes and the error handling. > > Hmm. That would still leave the backpatch issue at hand, which is > kind of confusing to leave as it is. Would it be complicated to > truncate the entire byte sequence in the error message and just give > up because we cannot do better if the input byte sequence is > incomplete? Maybe I've misunderstood, but isn't that what's being done in v2? > > Maybe I'm missing > > code somewhere, but I don't see a conversion routine from > > json_errdetail() to the actual client/locale encoding. (And the parser > > does not support multibyte input_encodings that contain ASCII in trail > > bytes.) > > Referring to json_lex_string() that does UTF-8 -> ASCII -> give-up in > its conversion for FRONTEND, I guess? Yep. This limitation looks > like a problem, especially if plugging that to libpq. Okay. How we deal with that will likely guide the "optimal" fix to error reporting, I think... Thanks, --Jacob