File pacemaker#3323-0001-Low-libcrmcommon-crm_xml_escape-shouldn-t-stop-on-Un.patch of Package pacemaker
From fb16237623ae1b69bf4f4f613ad95bae0320d9b9 Mon Sep 17 00:00:00 2001
From: Reid Wahl <nrwahl@protonmail.com>
Date: Thu, 1 Feb 2024 12:05:41 -0800
Subject: [PATCH] Low: libcrmcommon: crm_xml_escape() shouldn't stop on Unicode
characters
If anything, it should ignore them, so we continue instead of breaking
out of the loop. (Otherwise, it makes no sense to increment index.)
I'm not confident that this is a valid and comprehensive test for
Unicode characters. The libxml2 function xmlEncodeEntitiesReentrant()
uses a different test that looks more thorough. However, that function
has its own share of issues (for example, not escaping quote
characters), so I'm hesitant to trust it.
Meanwhile, a similar but distinct libxml2 function
xmlEncodeSpecialChars() does nothing special to Unicode characters,
assuming instead that it will "just work". See libxml2 source code
(currently in entities.c) if you're curious.
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
---
lib/common/xml.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: pacemaker-2.1.7+20231219.0f7f88312/lib/common/xml.c
===================================================================
--- pacemaker-2.1.7+20231219.0f7f88312.orig/lib/common/xml.c
+++ pacemaker-2.1.7+20231219.0f7f88312/lib/common/xml.c
@@ -1355,8 +1355,9 @@ crm_xml_escape(const char *text)
CRM_ASSERT(copy != NULL);
for (size_t index = 0; index < length; index++) {
if(copy[index] & 0x80 && copy[index+1] & 0x80){
+ // @TODO Is this a valid test for Unicode characters?
index++;
- break;
+ continue;
}
switch (copy[index]) {
case 0: