Vinzenz Feenstra has uploaded a new change for review.

Change subject: Remove contra productive _string_check
......................................................................

Remove contra productive _string_check

_string_check is rather harmful when using the new filtering. It creates
non-unicode strings out of valid strings.
The new unicode validation code covers the boundaries much better than
_string_check therefore we remove it.

Change-Id: Id01d8dc1374ae33435c5aefaae559ab8aa0ff062
Signed-off-by: Vinzenz Feenstra <[email protected]>
---
M ovirt-guest-agent/VirtIoChannel.py
1 file changed, 2 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-guest-agent 
refs/changes/11/18811/1

diff --git a/ovirt-guest-agent/VirtIoChannel.py 
b/ovirt-guest-agent/VirtIoChannel.py
index dd68668..5383b04 100644
--- a/ovirt-guest-agent/VirtIoChannel.py
+++ b/ovirt-guest-agent/VirtIoChannel.py
@@ -19,7 +19,6 @@
 import os
 import platform
 import time
-import locale
 import unicodedata
 
 
@@ -40,23 +39,6 @@
     .union(set(range(0xE, 0x1F + 1)))\
     .union(set(range(0x7F, 0x84 + 1)))\
     .union(set(range(0x86, 0x9F + 1)))
-
-
-def _string_check(str):
-    """
-    This function tries to convert the given string to a valid representable
-    form. Normal and valid unicode strings should not fail this test. Invalid
-    encodings will fail this and might get characters replaced.
-    """
-    try:
-        str.encode(locale.getpreferredencoding(), 'strict')
-    except UnicodeError:
-        try:
-            return str.encode('ascii', 'replace')
-        except UnicodeError:
-            # unrepresentable string
-            return unicode()
-    return unicode(str)
 
 
 def _filter_xml_chars(u):
@@ -94,7 +76,7 @@
 
 def _filter_object(obj):
     """
-    Apply _filter_xml_chars and _string_check on all strings in the given
+    Apply _filter_xml_chars on all strings in the given
     object
     """
     def filt(o):
@@ -105,7 +87,7 @@
         if isinstance(o, tuple):
             return tuple(map(filt, o))
         if isinstance(o, basestring):
-            return _filter_xml_chars(_string_check(o))
+            return _filter_xml_chars(o)
         return o
 
     return filt(obj)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id01d8dc1374ae33435c5aefaae559ab8aa0ff062
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-guest-agent
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to