Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pywU7-0002O0-LF for pgsql-bugs@arkaria.postgresql.org; Tue, 16 May 2023 15:21:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pywU6-0004Zy-IY for pgsql-bugs@arkaria.postgresql.org; Tue, 16 May 2023 15:21:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pywU6-0004Z2-9x for pgsql-bugs@lists.postgresql.org; Tue, 16 May 2023 15:21:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pywU2-000A7q-Ns for pgsql-bugs@lists.postgresql.org; Tue, 16 May 2023 15:21:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 34GFL0gn2650679; Tue, 16 May 2023 11:21:01 -0400 From: Tom Lane To: Sergiu Ignat cc: pgsql-bugs@lists.postgresql.org Subject: Re: XML element with special characters can be created, serialized, but not deserialized In-reply-to: References: Comments: In-reply-to Sergiu Ignat message dated "Tue, 16 May 2023 13:02:20 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2650677.1684250460.1@sss.pgh.pa.us> Date: Tue, 16 May 2023 11:21:00 -0400 Message-ID: <2650678.1684250460@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sergiu Ignat writes: > I am using PostgreSQL 13.8 and I think that I found an issue with XML > serialization and deserialization. Hmm. The root cause here seems to be that escape_xml() thinks it doesn't need to escape ASCII control characters, other than CR (\r). Which is a bit backwards, because after some googling I conclude that XML 1.1 requires all C0 and C1 control characters to be represented as numeric escapes *except* CR, LF, and TAB [1]. What we probably ought to do is escape all except LF and TAB. However, I'm a bit hesitant to back-patch such a behavioral change. Maybe change this in HEAD (v16) only? regards, tom lane [1] https://www.w3.org/International/questions/qa-controls