Vinzenz Feenstra has uploaded a new change for review.

Change subject: agent: XML Character filtering improvement
......................................................................

agent: XML Character filtering improvement

The filtering of invalid characters for XML documents must not be
performed on unicode strings but on the encoded utf-8 string.
If we do not do this we'll be missing out on filtering everything
what would destroy the XML documents.

Change-Id: I21b970c8552b3f238c6bfe9271c5c5a37d40ea4d
Signed-off-by: Vinzenz Feenstra <[email protected]>
---
M vdsm/guestIF.py
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/13809/1

diff --git a/vdsm/guestIF.py b/vdsm/guestIF.py
index 675b78e..21cd916 100644
--- a/vdsm/guestIF.py
+++ b/vdsm/guestIF.py
@@ -47,7 +47,16 @@
         else:
             return c
 
-    return ''.join(maskRestricted(c) for c in u)
+    # The filtering must be performed on utf-8 encoded strings to be effective
+    if isinstance(u, unicode):
+        try:
+            u = u.encode('utf-8')
+        except UnicodeError:
+            try:
+                u = u.encode('ascii', 'replace')
+            except UnicodeError:
+                return u''
+    return unicode(''.join(maskRestricted(c) for c in u))
 
 
 class MessageState:


--
To view, visit http://gerrit.ovirt.org/13809
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21b970c8552b3f238c6bfe9271c5c5a37d40ea4d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to